| 1 |
|
| 2 |
|
| 3 |
from odoo.tests import tagged |
| 4 |
|
| 5 |
from odoo.tests.common import HttpCase |
| 6 |
from odoo.addons.website_sale_collect.tests.common import ClickAndCollectCommon |
| 7 |
|
| 8 |
|
| 9 |
@tagged('post_install', '-at_install') |
| 10 |
class TestClickAndCollectFlow(HttpCase, ClickAndCollectCommon): |
| 11 |
|
| 12 |
@classmethod |
| 13 |
def setUpClass(cls): |
| 14 |
super().setUpClass() |
| 15 |
cls.storable_product.name = "Test CAC Product" |
| 16 |
cls.provider.write({ |
| 17 |
'state': 'enabled', |
| 18 |
'is_published': True, |
| 19 |
}) |
| 20 |
cls.in_store_dm.warehouse_ids[0].partner_id = cls.env['res.partner'].create({ |
| 21 |
**cls.dummy_partner_address_values, |
| 22 |
'name': "Shop 1", |
| 23 |
'partner_latitude': 1.0, |
| 24 |
'partner_longitude': 2.0, |
| 25 |
}) |
| 26 |
|
| 27 |
def test_buy_with_click_and_collect_as_public_user(self): |
| 28 |
""" |
| 29 |
Test the basic flow of buying with click and collect as a public user with more than |
| 30 |
one delivery method available |
| 31 |
""" |
| 32 |
self.start_tour('/', 'website_sale_collect_widget') |
| 33 |
|
| 34 |
def test_default_location_is_set_for_pick_up_in_store(self): |
| 35 |
""" |
| 36 |
Verify that when `Pick Up In Store` is the only active delivery method with the only wh, |
| 37 |
the checkout flow automatically sets the default store location. |
| 38 |
""" |
| 39 |
self.env['delivery.carrier'].search([]).active = False |
| 40 |
self.in_store_dm.active = True |
| 41 |
self.start_tour('/', 'website_sale_collect_buy_product_default_location_pick_up_in_store') |
| 42 |
|
| 43 |
def test_cash_on_delivery_resets_on_in_store_type(self): |
| 44 |
""" |
| 45 |
Ensure that when a carrier with cash-on-delivery enabled is switched |
| 46 |
to the 'in_store' delivery type, the 'allow_cash_on_delivery' field |
| 47 |
is automatically reset to False. |
| 48 |
""" |
| 49 |
carrier = self.env['delivery.carrier'].create({ |
| 50 |
'name': 'Test Carrier', |
| 51 |
'allow_cash_on_delivery': True, |
| 52 |
'delivery_type': 'fixed', |
| 53 |
'product_id': self.storable_product.id, |
| 54 |
}) |
| 55 |
carrier.delivery_type = 'in_store' |
| 56 |
self.assertEqual(carrier.allow_cash_on_delivery, False) |