Browse Source

[IMP] Improve readability of with_context(skip_check_zip=True)

* Easier to read by splitting lines
* Also, set context before the loop
14.0
Ivàn Todorovich 3 years ago
parent
commit
23b8d16f68
  1. 21
      base_location/models/res_company.py

21
base_location/models/res_company.py

@ -33,7 +33,6 @@ class ResCompany(models.Model):
inverse="_inverse_zip_id",
help="Use the city name or the zip code to search the location",
)
country_enforce_cities = fields.Boolean(
related="partner_id.country_id.enforce_cities"
)
@ -48,24 +47,20 @@ class ResCompany(models.Model):
return res
def _inverse_city_id(self):
for company in self:
company.with_context(
skip_check_zip=True
).partner_id.city_id = company.city_id
for company in self.with_context(skip_check_zip=True):
company.partner_id.city_id = company.city_id
def _inverse_zip_id(self):
for company in self:
company.with_context(skip_check_zip=True).partner_id.zip_id = company.zip_id
for company in self.with_context(skip_check_zip=True):
company.partner_id.zip_id = company.zip_id
def _inverse_state(self):
return super(
ResCompany, self.with_context(skip_check_zip=True)
)._inverse_state()
self = self.with_context(skip_check_zip=True)
return super(ResCompany, self)._inverse_state()
def _inverse_country(self):
return super(
ResCompany, self.with_context(skip_check_zip=True)
)._inverse_country()
self = self.with_context(skip_check_zip=True)
return super(ResCompany, self)._inverse_country()
@api.onchange("zip_id")
def _onchange_zip_id(self):

Loading…
Cancel
Save