update code for manual price calculation

This commit is contained in:
Pawan Kumar 2021-01-13 12:33:59 +05:30
parent 255ebe3e9b
commit 320956aa25
1 changed files with 19 additions and 16 deletions

View File

@ -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, store=True)
cost = fields.Float("Cost", default=0.0)
consultant_cost = fields.Float("Actual Cost", compute='_compute_timesheet_hour', default=0.0)
hour_distribution = fields.Selection(related='project_id.hour_distribution')
@ -213,22 +213,25 @@ class InheritProjectProductEmployeeMap(models.Model):
@api.onchange('project_id.budgeted_revenue', 'price_unit', 'distribution_per', 'employee_id', 'role')
def _compute_total_cost(self):
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
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:
val.cost = 0.0
# val.cost = val.budgeted_qty * val.price_unit
# val.consultant_cost = val.timesheet_hour * val.employee_price
# self.project_id.onchange_budgeted_hour()
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()
@api.onchange('price_unit', 'budgeted_qty')
def _calculate_total_cost(self):
if self.project_id.project_type == 'hours_in_consultant':
if self.hour_distribution == 'Manual':
self.cost = self.price_unit * self.budgeted_qty
@api.depends('sale_line_id', 'sale_line_id.price_unit', 'timesheet_product_id')
def _compute_price_unit(self):