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.

31 lines
1.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from odoo import models, api
  5. from .. import fields
  6. class ResPartner(models.Model):
  7. _inherit = 'res.partner'
  8. _phone_name_sequence = 10
  9. phone = fields.Phone(country_field='country_id', partner_field='parent_id')
  10. mobile = fields.Phone(
  11. country_field='country_id', partner_field='parent_id')
  12. fax = fields.Fax(country_field='country_id', partner_field='parent_id')
  13. @api.multi
  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()