diff --git a/base_location/__manifest__.py b/base_location/__manifest__.py index e01879bc9..af25b4d44 100644 --- a/base_location/__manifest__.py +++ b/base_location/__manifest__.py @@ -1,10 +1,10 @@ # Copyright 2016 Nicolas Bessi, Camptocamp SA -# Copyright 2018 Tecnativa - Pedro M. Baeza +# Copyright 2018-2019 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Location management (aka Better ZIP)', - 'version': '12.0.1.0.1', + 'version': '12.0.1.0.2', 'depends': [ 'base_address_city', 'contacts', diff --git a/base_location/models/res_partner.py b/base_location/models/res_partner.py index e4d38b079..0d45f6901 100644 --- a/base_location/models/res_partner.py +++ b/base_location/models/res_partner.py @@ -21,7 +21,7 @@ class ResPartner(models.Model): '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)] @@ -49,6 +49,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):