Browse Source

Reverting 70fc439574

and removing _check_zip as preventing to correctly save company data.

FIX the following cases:

 - open company form
 - set zip_id
 - save
 - user is blocked

and

 - open company form
 - set state_id
 - save
 - state_id is not saved
pull/733/head
eLBati 6 years ago
parent
commit
987406ee70
  1. 2
      base_location/__manifest__.py
  2. 14
      base_location/models/res_company.py
  3. 20
      base_location/models/res_partner.py

2
base_location/__manifest__.py

@ -4,7 +4,7 @@
{
'name': 'Location management (aka Better ZIP)',
'version': '12.0.1.0.1',
'version': '12.0.1.0.2',
'depends': [
'base_address_city',
'contacts',

14
base_location/models/res_company.py

@ -47,21 +47,11 @@ class ResCompany(models.Model):
def _inverse_city_id(self):
for company in self:
company.with_context(
skip_check_zip=True).partner_id.city_id = company.city_id
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
def _inverse_state(self):
return super(ResCompany, self.with_context(
skip_check_zip=True))._inverse_state()
def _inverse_country(self):
return super(ResCompany, self.with_context(
skip_check_zip=True))._inverse_country()
company.partner_id.zip_id = company.zip_id
@api.onchange('zip_id')
def _onchange_zip_id(self):

20
base_location/models/res_partner.py

@ -50,26 +50,6 @@ class ResPartner(models.Model):
vals.update({'state_id': self.zip_id.city_id.state_id})
self.update(vals)
@api.constrains('zip_id', 'country_id', 'city_id', 'state_id')
def _check_zip(self):
if self.env.context.get('skip_check_zip'):
return
for rec in self:
if not rec.zip_id:
continue
if rec.zip_id.city_id.state_id != rec.state_id:
raise ValidationError(_(
"The state of the partner %s differs from that in "
"location %s") % (rec.name, rec.zip_id.name))
if rec.zip_id.city_id.country_id != rec.country_id:
raise ValidationError(_(
"The country of the partner %s differs from that in "
"location %s") % (rec.name, rec.zip_id.name))
if rec.zip_id.city_id != rec.city_id:
raise ValidationError(_(
"The city of partner %s differs from that in "
"location %s") % (rec.name, rec.zip_id.name))
@api.onchange('state_id')
def _onchange_state_id(self):
vals = {}

Loading…
Cancel
Save