[FIX] website_sale_delivery: correct adress states
Steps to reproduce: - set shipping methods country to mexico (empty states) - fill an order on website on check out select seprate shipping/billing - on billing set country as US - on shipping the only country avialable is mexico - avialable states are the ones from the US not mexico Bug: the states are set from the country of the customer even though it isn't an option on any carrier. bug was introduced by this commit[1] Fix: revert the mentioned commit(1) since a new commit[2] was introduced that correctly handles that use case too [1]:https://github.com/odoo/odoo/commit/d59fe9c58c2dcc2bf6613adb7ac3662597b50496 [2]:https://github.com/odoo/odoo/commit/297641da69982d6c76bd591296636b479cabf657 opw-3230361 closes odoo/odoo#128349 X-original-commit: c59bc765f186858bffb642987cd88fcb80fe262a Signed-off-by: Walid Hanniche (waha) <waha@odoo.com> Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
@@ -34,7 +34,5 @@ class ResCountry(models.Model):
|
||||
states = res
|
||||
break
|
||||
states |= carrier.state_ids
|
||||
if not states:
|
||||
states = states.search([('country_id', '=', self.id)])
|
||||
res = res & states
|
||||
return res
|
||||
|
||||
@@ -34,3 +34,25 @@ class TestWebsiteSaleDeliveryController(PaymentCommon):
|
||||
order = self.website.sale_get_order(force_create=True)
|
||||
order.transaction_ids = self._create_transaction(flow='redirect', state='draft')
|
||||
self.Controller.update_eshop_carrier(carrier_id=1)
|
||||
|
||||
def test_address_states(self):
|
||||
US = self.env.ref('base.us')
|
||||
MX = self.env.ref('base.mx')
|
||||
|
||||
# Set all carriers to mexico
|
||||
self.env['delivery.carrier'].sudo().search([('website_published', '=', True)]).country_ids = [(6, 0, [MX.id])]
|
||||
|
||||
# Create a new carrier to only one state in mexico
|
||||
self.env['delivery.carrier'].create({
|
||||
'name': "One_state",
|
||||
'product_id': self.env['product.product'].create({'name': "delivery product"}).id,
|
||||
'website_published': True,
|
||||
'country_ids': [(6, 0, [MX.id])],
|
||||
'state_ids': [(6, 0, [MX.state_ids.ids[0]])]
|
||||
})
|
||||
|
||||
country_info = self.Controller.country_infos(country=MX, mode="shipping")
|
||||
self.assertEqual(len(country_info['states']), len(MX.state_ids))
|
||||
|
||||
country_info = self.Controller.country_infos(country=US, mode="shipping")
|
||||
self.assertEqual(len(country_info['states']), 0)
|
||||
|
||||
Reference in New Issue
Block a user