You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
949 B

  1. # Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
  2. # Copyright 2016 Tecnativa S.L. - Vicent Cubells
  3. # Copyright 2018 Eficent Business and IT Consulting Services, S.L.
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import api, exceptions, fields, models, _
  6. class ResPartner(models.Model):
  7. _inherit = 'res.partner'
  8. industry_id = fields.Many2one(string='Main Industry')
  9. secondary_industry_ids = fields.Many2many(
  10. comodel_name='res.partner.industry', string="Secondary Industries",
  11. domain="[('id', '!=', industry_id)]")
  12. @api.constrains('industry_id', 'secondary_industry_ids')
  13. def _check_industries(self):
  14. for partner in self:
  15. if partner.industry_id in partner.secondary_industry_ids:
  16. raise exceptions.ValidationError(
  17. _('The main industry must be different '
  18. 'from the secondary industries.'))