Browse Source

[FIX] base_location: Don't apply domain when cities are not enforced

And also reset city_id for avoiding incoherent information in that case.

Fixes #762
14.0
Pedro M. Baeza 5 years ago
parent
commit
96b98f2ca8
  1. 2
      base_location/__manifest__.py
  2. 4
      base_location/models/res_partner.py

2
base_location/__manifest__.py

@ -4,7 +4,7 @@
{
"name": "Location management (aka Better ZIP)",
"version": "13.0.1.0.0",
"version": "13.0.1.0.1",
"depends": ["base_address_city", "contacts"],
"author": (
"Camptocamp,"

4
base_location/models/res_partner.py

@ -17,7 +17,7 @@ class ResPartner(models.Model):
super()._onchange_city_id()
if self.zip_id and self.city_id != self.zip_id.city_id:
self.update({"zip_id": False, "zip": False, "city": False})
if self.city_id:
if self.city_id and self.country_enforce_cities:
return {"domain": {"zip_id": [("city_id", "=", self.city_id.id)]}}
return {"domain": {"zip_id": []}}
@ -41,6 +41,8 @@ class ResPartner(models.Model):
if self.zip_id.city_id.state_id:
vals.update({"state_id": self.zip_id.city_id.state_id})
self.update(vals)
elif not self.country_enforce_cities:
self.city_id = False
@api.constrains("zip_id", "country_id", "city_id", "state_id")
def _check_zip(self):

Loading…
Cancel
Save