From 23b8d16f68a83aaeeae4f142ad046b8b472138a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A0n=20Todorovich?= Date: Thu, 8 Jul 2021 15:48:31 -0300 Subject: [PATCH] [IMP] Improve readability of with_context(skip_check_zip=True) * Easier to read by splitting lines * Also, set context before the loop --- base_location/models/res_company.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/base_location/models/res_company.py b/base_location/models/res_company.py index 849152f8e..eb691e63a 100644 --- a/base_location/models/res_company.py +++ b/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):