From 050e4b58aa43f5fb2a7127593ab4cebbfc64b559 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 7 Jan 2021 12:03:39 +0530 Subject: [PATCH] update changes --- cor_custom/models/project.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/cor_custom/models/project.py b/cor_custom/models/project.py index 34c1005..076096f 100755 --- a/cor_custom/models/project.py +++ b/cor_custom/models/project.py @@ -49,7 +49,7 @@ class Project(models.Model): consultant_cost = fields.Float("Actual Cost", compute='_compute_consultant_timesheet_hours') other_expenses = fields.Float(string='Other Expenses', related='expenses_amt') total_expenses = fields.Float(string='Total Expenses', digits=(16, 2), compute='_compute_calc', store=True) - hourly_rate = fields.Float("Hourly Rate", compute='onchange_compute_values', store=True) + hourly_rate = fields.Float("Hourly Rate", compute='_compute_consultant_timesheet_hours') hourly_rate2 = fields.Float("Hourly Ratee") budgeted_hour_week = fields.Float("Budgeted Hours(per week)", compute='onchange_compute_values', store=True) profit_amt = fields.Float(string='Profit Amount', digits=(16, 2), compute='_compute_calc', store=True) @@ -70,6 +70,10 @@ class Project(models.Model): for rec in record.sale_line_employee_ids: consultant_cost = consultant_cost + rec.consultant_cost record.consultant_cost = consultant_cost + total_exp = record.consultant_cost + record.expenses_amt + record.total_expenses = total_exp + if record.budgeted_hours > 0.0: + record.hourly_rate = (record.budgeted_revenue / record.budgeted_hours) @api.depends('manager_per', 'hour_distribution') def compute_percentage_hours(self): @@ -106,41 +110,23 @@ class Project(models.Model): @api.depends('sale_line_employee_ids', 'budgeted_hours') def onchange_compute_values(self): for record in self: - print('TTTTTTTTTTTTTTTTTTTTTT') hour = 0.0 cost = 0.0 - #consultant_cost = 0.0 budgeted_hour_week = 0.0 for rec in record.sale_line_employee_ids: hour = hour + rec.budgeted_qty - #consultant_cost = consultant_cost + rec.consultant_cost - #print('SSSSSSSSSSSSSS', consultant_cost) cost = cost + rec.cost budgeted_hour_week = budgeted_hour_week + rec.budgeted_hour_week if record.project_type == 'hours_in_consultant': record.cost = cost record.budgeted_hours = hour - if hour > 0.0: - record.hourly_rate = (cost / hour) + #if hour > 0.0: + #record.hourly_rate = (cost / hour) else: record.cost = record.budgeted_hours * record.hourly_rate - if record.budgeted_hours > 0.0: - record.hourly_rate = (record.budgeted_revenue / record.budgeted_hours) - #record.consultant_cost = consultant_cost record.budgeted_hour_week = budgeted_hour_week - # price_unit = 0.0 - # count = 0.0 - # for rec in record.sale_line_employee_ids: - # price_unit = price_unit + rec.price_unit - # count = count + 1 - # if record.budgeted_hours > 0.0 and count > 0.0: - # avg =(record.budgeted_hours/count) - # hourly_rate = price_unit * avg - # record.hourly_rate = (price_unit * avg)/record.budgeted_hours - - class InheritProjectProductEmployeeMap(models.Model): _inherit = 'project.sale.line.employee.map'