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.

22 lines
836 B

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Antiun Ingenieria S.L. - Javier Iniesta
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import models, fields, api, exceptions, _
  5. class ResPartner(models.Model):
  6. _inherit = 'res.partner'
  7. sector_id = fields.Many2one(comodel_name='res.partner.sector',
  8. string='Main Sector')
  9. secondary_sector_ids = fields.Many2many(
  10. comodel_name='res.partner.sector', string="Secondary Sectors",
  11. domain="[('id', '!=', sector_id)]")
  12. @api.constrains('sector_id', 'secondary_sector_ids')
  13. def _check_sectors(self):
  14. if self.sector_id in self.secondary_sector_ids:
  15. raise exceptions.Warning(_('The main sector must be different '
  16. 'from the secondary sectors.'))