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.

34 lines
1.0 KiB

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