Label, rem and compute changed
This commit is contained in:
parent
3977a4a261
commit
fb1420cf5b
|
@ -19,8 +19,8 @@ class ProjectConsultantHrs(models.Model):
|
|||
start_date = fields.Date('Start Date', required=True)
|
||||
end_date = fields.Date('End Date', required=True)
|
||||
percentage = fields.Float("Percentage (%)")
|
||||
budgeted_hours = fields.Float("Budgeted Hours", compute='_compute_budgeted_hours', store=True)
|
||||
actual_hours = fields.Float("Actual Hours", compute='_compute_actual_hours', store=True)
|
||||
budgeted_hours = fields.Float("Budgeted Hours for period", compute='_compute_budgeted_hours', store=True)
|
||||
actual_hours = fields.Float("Actual Hours for period", compute='_compute_actual_hours', store=True)
|
||||
#hours_type = fields.Selection([('Budgeted Hours', 'Budgeted Hours'), ('Actual Hours', 'Actual Hours')], default="Budgeted Hours", string="Type")
|
||||
|
||||
@api.constrains('start_date', 'end_date')
|
||||
|
@ -75,7 +75,8 @@ class ProjectConsultantHrs(models.Model):
|
|||
else:
|
||||
val.budgeted_hours = 0
|
||||
|
||||
@api.depends('project_id', 'start_date', 'end_date', 'project_id.timesheet_ids')
|
||||
@api.depends('project_id', 'start_date', 'end_date', 'project_id.timesheet_ids', 'project_id.timesheet_ids.date',
|
||||
'project_id.timesheet_ids.project_id', 'project_id.timesheet_ids.employee_id', 'project_id.timesheet_ids.start_time', 'project_id.timesheet_ids.end_time')
|
||||
def _compute_actual_hours(self):
|
||||
Timesheet = self.env['account.analytic.line']
|
||||
for val in self:
|
||||
|
|
|
@ -18,7 +18,6 @@ class ProjectMultiBudgetAssign(models.TransientModel):
|
|||
res_id = self._context.get('active_id')
|
||||
record = self.env['project.project'].browse(res_id)
|
||||
lines = []
|
||||
print("record.sale_line_employee_ids", record.sale_line_employee_ids)
|
||||
for rec in record.sale_line_employee_ids:
|
||||
cons = {}
|
||||
all_cons = self.env['project.consultant.hrs'].search([('employee_id','=',rec.employee_id.id),('project_id','=',rec.project_id.id)])
|
||||
|
@ -77,10 +76,18 @@ class ProjectMultiBudgetAssignLine(models.TransientModel):
|
|||
emp_map_id = fields.Many2one('project.sale.line.employee.map', string="Consultant Map", required=True)
|
||||
employee_id = fields.Many2one('hr.employee', string="Consultant", required=True)
|
||||
budgeted_qty = fields.Float(string='Budgeted Hours', related="emp_map_id.budgeted_qty")
|
||||
all_percentage = fields.Float("Total Allocated (%)", compute='_compute_allocation')
|
||||
rem_percentage = fields.Float("Total Unallocated (%)", compute='_compute_allocation')
|
||||
percentage = fields.Float("Percentage (%)")
|
||||
budgeted_hours = fields.Float("Budgeted Hours", compute='_compute_budgeted_hours', store=True)
|
||||
all_percentage = fields.Float("Total Allocated %", compute='_compute_allocation')
|
||||
rem_percentage = fields.Float("Total Unallocated %", compute='_compute_allocation')
|
||||
percentage = fields.Float("Percentage %")
|
||||
remaining = fields.Float("Remaining Percentage %")
|
||||
budgeted_hours = fields.Float("Budgeted Hours for period", compute='_compute_budgeted_hours', store=True)
|
||||
|
||||
@api.onchange('percentage')
|
||||
def onchange_employee_id(self):
|
||||
res = self.rem_percentage - self.percentage
|
||||
if res < 0:
|
||||
raise ValidationError(_('Remaining percentage should not be negative'))
|
||||
self.remaining = res
|
||||
|
||||
@api.depends('project_id', 'employee_id')
|
||||
def _compute_allocation(self):
|
||||
|
@ -93,9 +100,11 @@ class ProjectMultiBudgetAssignLine(models.TransientModel):
|
|||
#res = all_per - 100
|
||||
val.all_percentage = all_per
|
||||
val.rem_percentage = 100 - all_per
|
||||
val.remaining = 100 - all_per
|
||||
else:
|
||||
val.all_percentage = 0
|
||||
val.rem_percentage = 0
|
||||
val.remaining = 0
|
||||
|
||||
@api.depends('project_id', 'employee_id', 'project_id.sale_line_employee_ids', 'percentage')
|
||||
def _compute_budgeted_hours(self):
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="project_id" invisible="1"/>
|
||||
<field name="project_multi_line" colspan="4">
|
||||
<field name="project_multi_line" nolabel="1" colspan="4">
|
||||
<tree editable="top" create="false">
|
||||
<field name="project_id" invisible="1"/>
|
||||
<field name="emp_map_id" invisible="1"/>
|
||||
|
@ -21,6 +21,7 @@
|
|||
<field name="rem_percentage"/>
|
||||
<field name="percentage"/>
|
||||
<field name="budgeted_hours"/>
|
||||
<field name="remaining" readonly="1" force_save="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
|
|
Loading…
Reference in New Issue