# -*- coding: utf-8 -*- from openerp import fields, models, api class ProjectServiceActivity(models.Model): _name = 'project.service.activity' name=fields.Char('Nombre', compute='_get_product_name') product_id = fields.Many2one('product.product', string='Planned work', domain=[('type', '=', 'service'),('sale_ok','=',True)]) time_spent = fields.Float(string='Estimated Time') work_date = fields.Datetime(string='Date') user_id = fields.Many2one('res.users', string='Responsible') task_id = fields.Many2one('project.service.task', string="Work id") work_cost = fields.Float(string="Service Cost") duration = fields.Float(string='Duration') completed = fields.Boolean(string="Completed") _defaults = { 'user_id': lambda obj, cr, uid, ctx=None: uid, 'work_date': fields.datetime.now(), } @api.onchange('product_id') def get_price(self): self.work_cost = self.product_id.lst_price api.one @api.depends('task_id','product_id') def _get_product_name(self): self.name = self.task_id.name + ' / ' + self.product_id.name