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

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