Browse Source

Merge PR #1150 into 14.0

Signed-off-by pedrobaeza
14.0
OCA-git-bot 3 years ago
parent
commit
cbce7c289f
  1. 4
      base_location/models/res_partner.py
  2. 23
      base_location/tests/test_base_location.py

4
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"]

23
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(

Loading…
Cancel
Save