compute the value for project without consultant

This commit is contained in:
Pawan Kumar 2021-01-06 12:21:32 +05:30
parent 1c72c2c356
commit 44a188b209
2 changed files with 17 additions and 19 deletions

View File

@ -48,13 +48,12 @@ class Project(models.Model):
consultant_cost = fields.Float("Consultant Cost", compute='onchange_compute_values', store=True)
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("Sum of Hourly rate", compute='onchange_compute_values', store=True)
hourly_rate = fields.Float("Hourly rate", compute='onchange_compute_values', store=True)
hourly_rate2 = fields.Float("Hourly rate")
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)
profit_per = fields.Float(string='Porfit Percentage', digits=(16, 2), compute='_compute_calc', store=True)
_sql_constraints = [
('end_date_greater', 'check(end_date >= start_date)', 'Error ! Ending Date cannot be set before Beginning Date.')
]
@ -75,7 +74,7 @@ class Project(models.Model):
if record.profit_amt > 0 and record.budgeted_revenue > 0:
record.profit_per = (record.profit_amt / record.budgeted_revenue) * 100
@api.depends('sale_line_employee_ids')
@api.depends('sale_line_employee_ids', 'hourly_rate2', 'budgeted_hours')
def onchange_compute_values(self):
for record in self:
if record.project_type == 'hours_in_consultant':
@ -90,25 +89,22 @@ class Project(models.Model):
budgeted_hour_week = budgeted_hour_week + rec.budgeted_hour_week
record.budgeted_hours = hour
record.cost = cost
print('kkkkkkkkkkkkk', consultant_cost)
record.consultant_cost = consultant_cost
if hour > 0.0:
record.hourly_rate = (cost/hour)
record.budgeted_hour_week = budgeted_hour_week
if record.project_type == 'hours_no_limit':
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
print('price_unit', price_unit, count)
if record.budgeted_hours > 0.0 and count > 0.0:
avg =(record.budgeted_hours/count)
hourly_rate = price_unit * avg
print('ppppppppppp', avg, hourly_rate)
record.hourly_rate = (price_unit * avg)/record.budgeted_hours
print('100000', record.hourly_rate)
record.consultant_cost = record.budgeted_hours * record.hourly_rate2
# 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

View File

@ -98,11 +98,13 @@
<field name="profit_per"/>
</group>
<group>
<field name="hourly_rate"/>
<field name="budgeted_hour_week"/>
<field name="budgeted_hours"
attrs="{'invisible': [('pricing_type','=','fixed_rate')], 'readonly': [('project_type','=','hours_in_consultant')],
'required': [('pricing_type','!=','fixed_rate')]}"/>
<field name="hourly_rate" attrs="{'invisible': [('project_type','=','hours_no_limit')]}"/>
<field name="hourly_rate2" attrs="{'invisible': [('project_type','!=','hours_no_limit')],
'required': [('project_type','=','hours_no_limit')]}"/>
<field name="budgeted_hour_week"/>
</group>
</group>