Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for record in records:
- today = datetime.datetime.today().date()
- order = record
- costTotal = 0.0
- costAnalytic = 0.0
- costForecasted = 0.0
- forecastedOrder = 0.0
- if record.analytic_account_id:
- account = record.analytic_account_id
- for line in account.line_ids:
- if line.is_timesheet == True:
- costAnalytic += line.amount
- forecastedProject = env['planning.slot'].sudo().search([('project_id.analytic_account_id','=',account.id)])
- for f in forecastedProject:
- if f.start_datetime.date() >= today: #el comienzo es después de hoy
- costForecasted += f.allocated_hours * f.employee_id.timesheet_cost
- elif f.start_datetime.date() < today and f.end_datetime.date() > today:
- elapsed = (today - f.start_datetime.date()).days
- shiftDuration = (f.end_datetime.date() - f.start_datetime.date()).days + 1
- costForecasted += (1 - (elapsed / shiftDuration)) * f.allocated_hours * f.employee_id.timesheet_cost
- costTotal = -1*costAnalytic + costForecasted
- record['x_sorder_costrealforecasted'] = costTotal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement