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.

35 lines
1.1 KiB

  1. # Copyright 2019 ACSONE SA/NV
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class ResPartnerIndustry(models.Model):
  5. _inherit = 'res.partner.industry'
  6. _parent_name = "parent_id"
  7. _parent_store = True
  8. _rec_name = 'complete_name'
  9. _order = 'complete_name'
  10. complete_name = fields.Char(
  11. 'Complete Name', compute='_compute_complete_name', store=True
  12. )
  13. parent_path = fields.Char(index=True)
  14. parent_id = fields.Many2one(comodel_name="res.partner.industry")
  15. child_ids = fields.One2many(
  16. comodel_name="res.partner.industry",
  17. inverse_name="parent_id",
  18. string="Children Industry",
  19. )
  20. @api.depends('name', 'parent_id.complete_name')
  21. def _compute_complete_name(self):
  22. for industry in self:
  23. if industry.parent_id:
  24. industry.complete_name = '%s / %s' % (
  25. industry.parent_id.complete_name,
  26. industry.name,
  27. )
  28. else:
  29. industry.complete_name = industry.name