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.

38 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2012-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 api, models
  6. class HrApplicant(models.Model):
  7. _name = 'hr.applicant'
  8. _inherit = ['hr.applicant', 'phone.validation.mixin']
  9. _phone_name_sequence = 50
  10. _phone_name_fields = ['partner_phone', 'partner_mobile']
  11. @api.onchange('partner_phone')
  12. def partner_phone_change(self):
  13. if self.partner_phone:
  14. self.partner_phone = self.phone_format(self.partner_phone)
  15. @api.onchange('partner_mobile')
  16. def partner_mobile_change(self):
  17. if self.partner_mobile:
  18. self.partner_mobile = self.phone_format(self.partner_mobile)
  19. def name_get(self):
  20. if self._context.get('callerid'):
  21. res = []
  22. for appl in self:
  23. if appl.partner_id:
  24. name = u'%s (%s)' % (appl.partner_id.name, appl.name)
  25. elif appl.partner_name:
  26. name = u'%s (%s)' % (appl.partner_name, appl.name)
  27. else:
  28. name = appl.name
  29. res.append((appl.id, name))
  30. return res
  31. else:
  32. return super(HrApplicant, self).name_get()