[FIX] base_address_extended: Changing country on a partner
Steps to reproduce the bug: 1. Create a Vendor with these address settings - Name: Vendor123 - Streer" Street: - Housnumber: 123 >> DO NOT ADD A COUNTRY => by default street_format = street_number street_number2 street_name 2. Create a purchase order for Vendor123 3. print the RFQ >> ADDRESS FORMAT "123 Street" => OK 4. Go to vendor123 and set "Netherlands" as a country 5. Print RFQ again Bug: >> The address was still in format "123 Street" => NOT OK When changing the country on a partner, the field street must be recomputed because the street_format depends on the country. opw:1865677
This commit is contained in:
@@ -137,6 +137,12 @@ class Partner(models.Model):
|
||||
for k, v in vals.items():
|
||||
partner[k] = v
|
||||
|
||||
def write(self, vals):
|
||||
res = super(Partner, self).write(vals)
|
||||
if 'country_id' in vals:
|
||||
self._set_street()
|
||||
return res
|
||||
|
||||
|
||||
class Company(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
@@ -51,5 +51,5 @@ class TestStreetFields(TransactionCase):
|
||||
self.write_and_assert(p1, {'street': 'Chaussee de Namur'}, 'Chaussee de Namur', 'Chaussee de Namur', '', '')
|
||||
self.write_and_assert(p1, {'street_name': 'Chee de Namur', 'street_number': '40'}, 'Chee de Namur, 40', 'Chee de Namur', '40', '')
|
||||
self.write_and_assert(p1, {'street_number2': '4'}, 'Chee de Namur, 40/4', 'Chee de Namur', '40', '4')
|
||||
#we don't recompute the street fields when we change the country
|
||||
self.write_and_assert(p1, {'country_id': self.env.ref('base.us').id}, 'Chee de Namur, 40/4', 'Chee de Namur', '40', '4')
|
||||
#we do recompute the street fields when we change the country
|
||||
self.write_and_assert(p1, {'country_id': self.env.ref('base.us').id}, '40/4 Chee de Namur', 'Chee de Namur', '40', '4')
|
||||
|
||||
Reference in New Issue
Block a user