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.

39 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
  3. # Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
  4. # Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com)
  5. # Antonio Espinosa <antonioea@antiun.com>
  6. # © 2015 Antiun Ingeniería S.L. - Jairo Llopis
  7. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  8. from openerp import models, fields
  9. class ResPartner(models.Model):
  10. _inherit = 'res.partner'
  11. department_id = fields.Many2one(
  12. "res.partner.department",
  13. "Department",
  14. oldname="department")
  15. class ResPartnerDepartment(models.Model):
  16. _name = 'res.partner.department'
  17. _order = "parent_left"
  18. _parent_order = "name"
  19. _parent_store = True
  20. _description = "Department"
  21. name = fields.Char(required=True, translate=True)
  22. parent_id = fields.Many2one(
  23. "res.partner.department",
  24. "Parent department",
  25. ondelete='restrict')
  26. child_ids = fields.One2many(
  27. "res.partner.department",
  28. "parent_id",
  29. "Child departments",
  30. oldname="children")
  31. parent_left = fields.Integer(index=True)
  32. parent_right = fields.Integer(index=True)