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.

28 lines
839 B

  1. # © 2014-2015 Tecnativa S.L. - Jairo Llopis
  2. # © 2016 Tecnativa S.L. - Vicent Cubells
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo import fields, models
  5. class ResPartner(models.Model):
  6. _inherit = "res.partner"
  7. department_id = fields.Many2one("res.partner.department", "Department")
  8. class ResPartnerDepartment(models.Model):
  9. _name = "res.partner.department"
  10. _order = "parent_path"
  11. _parent_order = "name"
  12. _parent_store = True
  13. _description = "Department"
  14. name = fields.Char(required=True, translate=True)
  15. parent_id = fields.Many2one(
  16. "res.partner.department", "Parent department", ondelete="restrict"
  17. )
  18. child_ids = fields.One2many(
  19. "res.partner.department", "parent_id", "Child departments"
  20. )
  21. parent_path = fields.Char(index=True)