diff --git a/base_location/models/res_partner.py b/base_location/models/res_partner.py index d939a6cf8..a8512287f 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 0f4cbad13..1ae54ed88 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(