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.

32 lines
994 B

  1. # -*- coding: utf-8 -*-
  2. # (c) 2016 credativ ltd. - Ondřej Kuzník
  3. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
  4. from openerp import models, fields, api
  5. class CrmPhonecall(models.Model):
  6. _inherit = "crm.phonecall"
  7. hr_applicant_id = fields.Many2one(
  8. 'hr.applicant', string='Applicant', ondelete='cascade')
  9. class HrApplicant(models.Model):
  10. _inherit = 'hr.applicant'
  11. phonecall_ids = fields.One2many('crm.phonecall', 'hr_applicant_id', string='Phone Calls')
  12. phonecall_count = fields.Integer(
  13. compute='_count_phonecalls', string='Number of Phonecalls',
  14. readonly=True)
  15. @api.multi
  16. @api.depends('phonecall_ids')
  17. def _count_phonecalls(self):
  18. cpo = self.env['crm.phonecall']
  19. for applicant in self:
  20. try:
  21. applicant.phonecall_count = cpo.search_count(
  22. [('hr_applicant_id', '=', applicant.id)])
  23. except:
  24. applicant.phonecall_count = 0