# -*- coding: utf-8 -*- from openerp import models, fields, api class ResPartnerMedicalFeature(models.Model): _inherit = 'res.partner' is_medic = fields.Boolean() medic = fields.Many2one( 'res.partner', string='Doctor', ondelete='restrict', domain=[('is_medic','=',True)] ) study_feature_ids = fields.One2many( 'study.feature', 'partner_id', string='Medical Feature', ) study_feature_count = fields.Integer( string='Numero de Estudios', compute='_get_study_features_count', ) @api.one @api.depends('study_feature_ids') def _get_study_features_count(self): self.study_feature_count = len(self.study_feature_ids)