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.

25 lines
900 B

9 years ago
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 odoo import models, fields, api, _
  6. from odoo.exceptions import ValidationError
  7. class ResPartner(models.Model):
  8. _inherit = 'res.partner'
  9. sector_id = fields.Many2one(comodel_name='res.partner.sector',
  10. string='Main Sector')
  11. secondary_sector_ids = fields.Many2many(
  12. comodel_name='res.partner.sector', string="Secondary Sectors",
  13. domain="[('id', '!=', sector_id)]")
  14. @api.constrains('sector_id', 'secondary_sector_ids')
  15. def _check_sectors(self):
  16. if self.sector_id in self.secondary_sector_ids:
  17. raise ValidationError(
  18. _('The main sector must be different '
  19. 'from the secondary sectors.'))