res_partner.py 739 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class ResPartnerMedicalFeature(models.Model):
  4. _inherit = 'res.partner'
  5. is_medic = fields.Boolean()
  6. medic = fields.Many2one(
  7. 'res.partner',
  8. string='Doctor',
  9. ondelete='restrict',
  10. domain=[('is_medic','=',True)]
  11. )
  12. study_feature_ids = fields.One2many(
  13. 'study.feature',
  14. 'partner_id',
  15. string='Medical Feature',
  16. )
  17. study_feature_count = fields.Integer(
  18. string='Numero de Estudios',
  19. compute='_get_study_features_count',
  20. )
  21. @api.one
  22. @api.depends('study_feature_ids')
  23. def _get_study_features_count(self):
  24. self.study_feature_count = len(self.study_feature_ids)