summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2018-07-19 14:04:27 +0200
committerGoffin Simon <sig@odoo.com>2018-07-23 09:27:05 +0200
commit88ff6beb016702cbda710aa31bbf10d51ab68fab (patch)
tree6eb78b33f6bba39dd37b4e23edc812fbec8353fc
parentcb4266787bca9722d62ee9b1b658db0d1b6d5f2a (diff)
[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
-rw-r--r--addons/base_address_extended/models/base_address_extended.py6
-rw-r--r--addons/base_address_extended/tests/test_street_fields.py4
2 files changed, 8 insertions, 2 deletions
diff --git a/addons/base_address_extended/models/base_address_extended.py b/addons/base_address_extended/models/base_address_extended.py
index 9a210dde769..07125811aed 100644
--- a/addons/base_address_extended/models/base_address_extended.py
+++ b/addons/base_address_extended/models/base_address_extended.py
@@ -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'
diff --git a/addons/base_address_extended/tests/test_street_fields.py b/addons/base_address_extended/tests/test_street_fields.py
index d5817070ffd..cf5598b624f 100644
--- a/addons/base_address_extended/tests/test_street_fields.py
+++ b/addons/base_address_extended/tests/test_street_fields.py
@@ -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')