|
|
if not self.env.user.has_group('hr_timesheet.group_hr_timesheet_user'):
self.timesheet_total_duration = 0
return
group_data = self.env['account.analytic.line']._read_group([
('reinvoice_move_id', 'in', self.ids), ('project_id', '!=', False),
], ['reinvoice_move_id'], ['unit_amount:sum'])
timesheet_unit_amount_dict = defaultdict(float)
timesheet_unit_amount_dict.update({timesheet_invoice.id: amount for timesheet_invoice, amount in group_data})
for invoice in self:
total_time = invoice.company_id.project_time_mode_id._compute_quantity(
timesheet_unit_amount_dict[invoice.id],
invoice.timesheet_encode_uom_id,
rounding_method='HALF-UP',
)
invoice.timesheet_total_duration = round(total_time)
|
|