res_partner.py 849 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class ResPartnerCar(models.Model):
  4. _inherit = 'res.partner'
  5. is_insurer = fields.Boolean()
  6. is_agent = fields.Boolean()
  7. car_ids = fields.One2many(
  8. 'car.service',
  9. 'partner_id',
  10. )
  11. car_count = fields.Integer(
  12. string='Numero de autos',
  13. compute='_get_car_count',
  14. )
  15. @api.one
  16. @api.depends('car_ids')
  17. def _get_car_count(self):
  18. self.car_count = len(self.car_ids)
  19. car_secure_ids = fields.One2many(
  20. 'car.service',
  21. 'secure_id',
  22. )
  23. car_secure_count = fields.Integer(
  24. string='Asegurados',
  25. compute='_get_car_secure_count',
  26. )
  27. @api.one
  28. @api.depends('car_secure_ids')
  29. def _get_car_secure_count(self):
  30. self.car_secure_count = len(self.car_secure_ids)