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.

26 lines
846 B

  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 odoo import models, fields, api
  5. class ResPartner(models.Model):
  6. _inherit = 'res.partner'
  7. phonecall_ids = fields.One2many(
  8. 'crm.phonecall', 'partner_id', string='Phone Calls')
  9. phonecall_count = fields.Integer(
  10. compute='_count_phonecalls', string='Number of Phonecalls',
  11. readonly=True)
  12. @api.multi
  13. @api.depends('phonecall_ids')
  14. def _count_phonecalls(self):
  15. cpo = self.env['crm.phonecall']
  16. for partner in self:
  17. try:
  18. partner.phonecall_count = cpo.search_count(
  19. [('partner_id', 'child_of', partner.id)])
  20. except:
  21. partner.phonecall_count = 0