Skip to content

Commit

Permalink
[FIX] base_address_extended: Changing country on a partner
Browse files Browse the repository at this point in the history
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
  • Loading branch information
simongoffin committed Jul 23, 2018
1 parent cb42667 commit 88ff6be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions addons/base_address_extended/models/base_address_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def _split_street(self):
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'
Expand Down
4 changes: 2 additions & 2 deletions addons/base_address_extended/tests/test_street_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ def test_02_res_partner_write(self):
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')

0 comments on commit 88ff6be

Please sign in to comment.