diff --git a/cor_custom/models/project.py b/cor_custom/models/project.py index 0e5b42d..5cc209f 100755 --- a/cor_custom/models/project.py +++ b/cor_custom/models/project.py @@ -183,7 +183,7 @@ class InheritProjectProductEmployeeMap(models.Model): currency_id = fields.Many2one('res.currency', string="Currency", compute='_compute_price_unit', store=True, readonly=False) sale_line_id = fields.Many2one('sale.order.line', "Service", domain=[('is_service', '=', True)]) - cost = fields.Float("Cost", default=0.0) + cost = fields.Float("Cost", default=0.0, store=True) consultant_cost = fields.Float("Actual Cost", compute='_compute_timesheet_hour', default=0.0) hour_distribution = fields.Selection(related='project_id.hour_distribution') @@ -213,19 +213,20 @@ class InheritProjectProductEmployeeMap(models.Model): @api.onchange('project_id.budgeted_revenue', 'price_unit', 'distribution_per', 'employee_id', 'role') def _compute_total_cost(self): - if self.project_id.project_type == 'hours_in_consultant': - if self.hour_distribution == 'Percentage': - if self.role == 'Manager': - self.cost = self.project_id.budgeted_revenue * (self.project_id.manager_per / 100) * ( - self.distribution_per / 100) - else: - self.cost = self.project_id.budgeted_revenue * (self.project_id.employee_per / 100) * ( - self.distribution_per / 100) - if self.price_unit > 0.0: - self.budgeted_qty = self.cost / self.price_unit - # val.cost = val.budgeted_qty * val.price_unit - # val.consultant_cost = val.timesheet_hour * val.employee_price - # self.project_id.onchange_budgeted_hour() + for val in self: + if val.project_id.project_type == 'hours_in_consultant': + if val.hour_distribution == 'Percentage': + if val.role == 'Manager': + val.cost = val.project_id.budgeted_revenue * (val.project_id.manager_per / 100) * ( + val.distribution_per / 100) + else: + val.cost = val.project_id.budgeted_revenue * (val.project_id.employee_per / 100) * ( + val.distribution_per / 100) + if val.price_unit > 0.0: + val.budgeted_qty = val.cost / val.price_unit + # val.cost = val.budgeted_qty * val.price_unit + # val.consultant_cost = val.timesheet_hour * val.employee_price + # self.project_id.onchange_budgeted_hour() @api.onchange('price_unit', 'budgeted_qty') def _calculate_total_cost(self):