# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) from odoo import api, fields, models class ResPartner(models.Model): _inherit = 'res.partner' rc_call_ids = fields.One2many( 'rc.call.history', 'partner_id', string='RingCentral Calls', ) rc_call_count = fields.Integer( string='Call Count', compute='_compute_rc_call_count', ) @api.depends('rc_call_ids') def _compute_rc_call_count(self): for partner in self: partner.rc_call_count = len(partner.rc_call_ids) def action_view_rc_calls(self): self.ensure_one() return { 'type': 'ir.actions.act_window', 'name': 'Calls', 'res_model': 'rc.call.history', 'view_mode': 'list,form', 'domain': [('partner_id', '=', self.id)], } def action_rc_call(self): """Placeholder for click-to-call -- actual dialing is handled by the JS widget.""" self.ensure_one() return { 'type': 'ir.actions.client', 'tag': 'display_notification', 'params': { 'title': 'Click-to-Dial', 'message': f'Use the RingCentral phone widget to call {self.phone or self.mobile or "this contact"}.', 'type': 'info', 'sticky': False, }, }