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.

36 lines
1.1 KiB

  1. # Copyright 2015-2017 ACSONE SA/NV (<https://acsone.eu>)
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo import models, fields, api
  4. class ResPartner(models.Model):
  5. _inherit = 'res.partner'
  6. def _get_separator(self):
  7. return ', '
  8. @api.multi
  9. @api.depends('academic_title_ids', 'academic_title_ids.sequence')
  10. def _compute_academic_title_display(self):
  11. for this in self:
  12. display_title = ""
  13. separator = this._get_separator()
  14. title_ids = this.academic_title_ids.sorted(lambda r: r.sequence)
  15. if title_ids:
  16. display_title = separator.join(
  17. [title.name for title in title_ids])
  18. this.academic_title_display = display_title
  19. academic_title_ids = fields.Many2many(
  20. string='Academic Titles',
  21. comodel_name='partner.academic.title',
  22. relation='partner_academic_title_ref',
  23. column1='partner_id',
  24. column2='academic_title_id'
  25. )
  26. academic_title_display = fields.Char(
  27. string='Academic Titles',
  28. compute='_compute_academic_title_display',
  29. store=True
  30. )