Browse Source

partner_industry_Secondary: Make api constrains multi to avoid error when create a company with 2 contacts

14.0
Sergio Teruel 5 years ago
committed by Surachet Saejueng
parent
commit
b245bdcf9a
  1. 9
      partner_industry_secondary/models/res_partner.py

9
partner_industry_secondary/models/res_partner.py

@ -17,7 +17,8 @@ class ResPartner(models.Model):
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
if self.industry_id in self.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
for partner in self:
if partner.industry_id in partner.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
Loading…
Cancel
Save