Browse Source

Merge pull request #716 from eLBati/12.0-fix-base_location-company

[12.0] FIX base_location blocking editing company address.
pull/722/head
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
70fc439574
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      base_location/__manifest__.py
  2. 14
      base_location/models/res_company.py
  3. 2
      base_location/models/res_partner.py
  4. 3
      base_location/tests/test_base_location.py

2
base_location/__manifest__.py

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

14
base_location/models/res_company.py

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

2
base_location/models/res_partner.py

@ -52,6 +52,8 @@ class ResPartner(models.Model):
@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):
if self.env.context.get('skip_check_zip'):
return
for rec in self: for rec in self:
if not rec.zip_id: if not rec.zip_id:
continue continue

3
base_location/tests/test_base_location.py

@ -135,6 +135,9 @@ class TestBaseLocation(common.SavepointCase):
'zip_id': self.barcelona.id, 'zip_id': self.barcelona.id,
}) })
def test_writing_company(self):
self.company.zip_id = self.barcelona
def test_constrains_partner_country(self): def test_constrains_partner_country(self):
"""Test partner country constraints""" """Test partner country constraints"""
partner = self.partner_obj.create({ partner = self.partner_obj.create({

Loading…
Cancel
Save