|
|
@ -27,6 +27,12 @@ class ResPartner(models.Model): |
|
|
|
'zip_id': [('city_id', '=', self.city_id.id)] |
|
|
|
}, |
|
|
|
} |
|
|
|
if self.country_id: |
|
|
|
return { |
|
|
|
'domain': { |
|
|
|
'zip_id': [('city_id.country_id', '=', self.country_id.id)] |
|
|
|
} |
|
|
|
} |
|
|
|
return {'domain': {'zip_id': []}} |
|
|
|
|
|
|
|
@api.onchange('country_id') |
|
|
@ -34,6 +40,15 @@ class ResPartner(models.Model): |
|
|
|
res = super()._onchange_country_id() |
|
|
|
if self.zip_id and self.zip_id.city_id.country_id != self.country_id: |
|
|
|
self.zip_id = False |
|
|
|
if self.country_id: |
|
|
|
city_zip_domain = { |
|
|
|
"zip_id": [("city_id.country_id", "=", self.country_id.id)] |
|
|
|
} |
|
|
|
if isinstance(res, dict): |
|
|
|
res.setdefault("domain", {}) |
|
|
|
res["domain"].update(city_zip_domain) |
|
|
|
else: |
|
|
|
res = {"domain": city_zip_domain} |
|
|
|
return res |
|
|
|
|
|
|
|
@api.onchange('zip_id') |
|
|
|