# -*- coding: utf-8 -*- from openerp import fields, models, api class ProjectServiceReserve(models.Model): _name = 'project.service.reserve' name = fields.Char('Nombre', compute='_get_reserve_name') partner_id = fields.Many2one('res.partner', string='Cliente', domain=[('customer', '=',True),('active','=',True)]) place = fields.Many2one('project.service', string='Lugar', domain=[('active','=',True)]) state = fields.Selection([ ('confirmed', 'Confirmado'), ('progress', 'En progreso'), ('done', 'Hecho'), ('cancel', 'Cancelado'), ], string='Status', readonly=True, default='confirmed', select=True) date = fields.Datetime(string='Date') date_reserve = fields.Datetime(string='Date Reserve') user_id = fields.Many2one('res.users', string='Responsible') _defaults = { 'state': 'confirmed', 'date': fields.datetime.now(), 'date_reserve': fields.datetime.now(), } @api.one @api.depends('partner_id','user_id') def _get_reserve_name(self): self.name = self.partner_id.name