# -*- encoding: utf-8 -*- from openerp import models, fields, api, _ class res_partner(models.Model): _inherit = 'res.partner' appointment_count = fields.Integer(compute='_appointment_count', string='Consultas') @api.one def _appointment_count(self): appointment = self.env['sis.stock.transfer'].search([('partner_id', '=', self.id),('type','=','appointment')]) self.appointment_count = len(appointment)