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.

42 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2014-2016 Tecnativa S.L. - Jairo Llopis
  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, _
  6. from openerp.exceptions import ValidationError
  7. class ResPartner(models.Model):
  8. _inherit = 'res.partner'
  9. job_position_id = fields.Many2one(
  10. "res.partner.job_position",
  11. "Categorized job position",
  12. oldname="job_position")
  13. class ResPartnerJobPosition(models.Model):
  14. _name = "res.partner.job_position"
  15. _order = "parent_left"
  16. _parent_order = "name"
  17. _parent_store = True
  18. _description = "Job position"
  19. name = fields.Char(required=True, translate=True)
  20. parent_id = fields.Many2one(
  21. "res.partner.job_position",
  22. "Parent", ondelete='restrict')
  23. child_ids = fields.One2many(
  24. "res.partner.job_position",
  25. "parent_id",
  26. "Children",
  27. oldname="children")
  28. parent_left = fields.Integer(index=True)
  29. parent_right = fields.Integer(index=True)
  30. @api.constrains('parent_id')
  31. def _check_parent_id(self):
  32. if not self._check_recursion():
  33. raise ValidationError(
  34. _('Error! You cannot create recursive job positions.'))