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.

30 lines
1.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016-2018 Akretion France
  3. # @author: Alexis de Lattre <alexis.delattre@akretion.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from odoo import models
  6. class ResPartner(models.Model):
  7. _name = 'res.partner'
  8. # inherit on phone.validation.mixin (same as in crm_phone_validation,
  9. # but base_phone only depends on phone_validation,
  10. # not on crm_phone_validation)
  11. _inherit = ['res.partner', 'phone.validation.mixin']
  12. _phone_name_sequence = 10
  13. _phone_name_fields = ['phone', 'mobile']
  14. def name_get(self):
  15. if self._context.get('callerid'):
  16. res = []
  17. for partner in self:
  18. if partner.parent_id and partner.parent_id.is_company:
  19. name = u'%s (%s)' % (partner.name, partner.parent_id.name)
  20. else:
  21. name = partner.name
  22. res.append((partner.id, name))
  23. return res
  24. else:
  25. return super(ResPartner, self).name_get()