project_service_reserve.py 1.1 KB

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. from openerp import fields, models, api
  3. class ProjectServiceReserve(models.Model):
  4. _name = 'project.service.reserve'
  5. name = fields.Char('Nombre', compute='_get_reserve_name')
  6. partner_id = fields.Many2one('res.partner', string='Cliente', domain=[('customer', '=',True),('active','=',True)])
  7. place = fields.Many2one('project.service', string='Lugar', domain=[('active','=',True)])
  8. state = fields.Selection([
  9. ('confirmed', 'Confirmado'),
  10. ('progress', 'En progreso'),
  11. ('done', 'Hecho'),
  12. ('cancel', 'Cancelado'),
  13. ], string='Status', readonly=True, default='confirmed', select=True)
  14. date = fields.Datetime(string='Date')
  15. date_reserve = fields.Datetime(string='Date Reserve')
  16. user_id = fields.Many2one('res.users', string='Responsible')
  17. _defaults = {
  18. 'state': 'confirmed',
  19. 'date': fields.datetime.now(),
  20. 'date_reserve': fields.datetime.now(),
  21. }
  22. @api.one
  23. @api.depends('partner_id','user_id')
  24. def _get_reserve_name(self):
  25. self.name = self.partner_id.name