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.

23 lines
898 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. if self.industry_id in self.secondary_industry_ids:
  15. raise exceptions.ValidationError(
  16. _('The main industry must be different '
  17. 'from the secondary industries.'))