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
878 B

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