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
12.0
Pedro M. Baeza 5 years ago
parent
commit
64aaafa45c
  1. 4
      base_location/__manifest__.py
  2. 4
      base_location/models/res_partner.py

4
base_location/__manifest__.py

@ -1,10 +1,10 @@
# Copyright 2016 Nicolas Bessi, Camptocamp SA # 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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Location management (aka Better ZIP)', 'name': 'Location management (aka Better ZIP)',
'version': '12.0.1.0.1',
'version': '12.0.1.0.2',
'depends': [ 'depends': [
'base_address_city', 'base_address_city',
'contacts', 'contacts',

4
base_location/models/res_partner.py

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

Loading…
Cancel
Save