# -*- coding: utf-8 -*- from openerp import models, fields, api class ResPartnerCar(models.Model): _inherit = 'res.partner' is_insurer = fields.Boolean() is_agent = fields.Boolean() car_ids = fields.One2many( 'car.service', 'partner_id', ) car_count = fields.Integer( string='Numero de autos', compute='_get_car_count', ) @api.one @api.depends('car_ids') def _get_car_count(self): self.car_count = len(self.car_ids) car_secure_ids = fields.One2many( 'car.service', 'secure_id', ) car_secure_count = fields.Integer( string='Asegurados', compute='_get_car_secure_count', ) @api.one @api.depends('car_secure_ids') def _get_car_secure_count(self): self.car_secure_count = len(self.car_secure_ids)