diff --git a/cor_custom/models/project.py b/cor_custom/models/project.py index 8d42ee8..b9ae8e6 100755 --- a/cor_custom/models/project.py +++ b/cor_custom/models/project.py @@ -119,13 +119,15 @@ class InheritProjectProductEmployeeMap(models.Model): for val in self: val.cost = val.budgeted_qty * val.price_unit - # @api.onchange('employee_id', 'budgeted_qty') - # def onchange_(self): - # for val in self: - # rec = 0.0 - # if val.project_id.project_type == 'hours_in_consultant': - # print('555555555') - # rec = rec + rec.budgeted_qty - # print('66666666666666666', rec) - # print('777777777', rec) - # self.budgeted_hours = rec + @api.depends('sale_line_id', 'sale_line_id.price_unit', 'timesheet_product_id') + def _compute_price_unit(self): + for line in self: + if line.sale_line_id: + line.price_unit = line.sale_line_id.price_unit + line.currency_id = line.sale_line_id.currency_id + elif line.timesheet_product_id: + line.price_unit = line.timesheet_product_id.lst_price + line.currency_id = line.timesheet_product_id.currency_id + else: + #line.price_unit = 0 + line.currency_id = False