From ba30203d3fe2d613d9947e083cf2fcb1a4b9b31a Mon Sep 17 00:00:00 2001 From: Flectra Community Bot Date: Sun, 24 Oct 2021 02:12:17 +0000 Subject: [PATCH] Automatic Update form OCA2FC Migrator --- README.md | 2 +- base_location/__manifest__.py | 2 +- base_location/models/res_partner.py | 4 ++++ base_location/tests/test_base_location.py | 23 +++++++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c665e5..365bfb4 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ addon | version | summary [partner_disable_gravatar](partner_disable_gravatar/) | 2.0.1.0.0| Disable automatic connection to gravatar.com [partner_external_map](partner_external_map/) | 2.0.1.0.0| Add Map and Map Routing buttons on partner form to open GMaps, OSM, Bing and others [partner_email_check](partner_email_check/) | 2.0.1.1.1| Validate email address field -[base_location](base_location/) | 2.0.1.2.1| Enhanced zip/npa management system +[base_location](base_location/) | 2.0.1.2.2| Enhanced zip/npa management system [partner_phone_secondary](partner_phone_secondary/) | 2.0.1.0.0| Adds a secondary phone number on partners [partner_contact_lang](partner_contact_lang/) | 2.0.1.0.0| Manage language in contacts [partner_manual_rank](partner_manual_rank/) | 2.0.1.0.0| Be able to manually flag partners as customer or supplier. diff --git a/base_location/__manifest__.py b/base_location/__manifest__.py index eb97d41..ff536e4 100644 --- a/base_location/__manifest__.py +++ b/base_location/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Location management (aka Better ZIP)", - "version": "2.0.1.2.1", + "version": "2.0.1.2.2", "depends": ["base_address_city", "contacts"], "author": ( "Camptocamp," diff --git a/base_location/models/res_partner.py b/base_location/models/res_partner.py index 8b40604..6ab173a 100644 --- a/base_location/models/res_partner.py +++ b/base_location/models/res_partner.py @@ -146,3 +146,7 @@ class ResPartner(models.Model): for node in doc.xpath("//field[@name='zip_id']"): node.attrib["domain"] = self._zip_id_domain() return etree.tostring(doc, encoding="unicode") + + @api.model + def _address_fields(self): + return super()._address_fields() + ["zip_id"] diff --git a/base_location/tests/test_base_location.py b/base_location/tests/test_base_location.py index a44b074..a33abb3 100644 --- a/base_location/tests/test_base_location.py +++ b/base_location/tests/test_base_location.py @@ -204,6 +204,29 @@ class TestBaseLocation(common.SavepointCase): self.company._onchange_state_id() self.assertEqual(self.company.country_id, self.company.state_id.country_id) + def test_partner_address_field_sync(self): + """Test that zip_id is correctly synced with parent of contact addresses""" + parent = self.env["res.partner"].create( + { + "name": "ACME Inc.", + "is_company": True, + "street": "123 Fake St.", + "city": "Springfield", + "state_id": self.barcelona.state_id.id, + "country_id": self.barcelona.country_id.id, + "zip_id": self.barcelona.id, + } + ) + contact = self.env["res.partner"].create( + { + "name": "John Doe", + "type": "contact", + "parent_id": parent.id, + } + ) + parent.zip_id = self.lausanne + self.assertEqual(contact.zip_id, self.lausanne, "Contact should be synced") + def test_display_name(self): """Test if the display_name is stored and computed properly""" self.assertEqual(