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.

40 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2012-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import models, api
  5. class HrApplicant(models.Model):
  6. _name = 'hr.applicant'
  7. _inherit = ['hr.applicant', 'phone.common']
  8. _phone_fields = ['partner_phone', 'partner_mobile']
  9. _phone_name_sequence = 50
  10. _country_field = None
  11. _partner_field = 'partner_id'
  12. @api.model
  13. def create(self, vals):
  14. vals_reformated = self._reformat_phonenumbers_create(vals)
  15. return super(HrApplicant, self).create(vals_reformated)
  16. @api.multi
  17. def write(self, vals):
  18. vals_reformated = self._reformat_phonenumbers_write(vals)
  19. return super(HrApplicant, self).write(vals_reformated)
  20. @api.multi
  21. def name_get(self):
  22. if self._context.get('callerid'):
  23. res = []
  24. for appl in self:
  25. if appl.partner_id:
  26. name = u'%s (%s)' % (appl.partner_id.name, appl.name)
  27. elif appl.partner_name:
  28. name = u'%s (%s)' % (appl.partner_name, appl.name)
  29. else:
  30. name = appl.name
  31. res.append((appl.id, name))
  32. return res
  33. else:
  34. return super(HrApplicant, self).name_get()