[FIX] hr_timesheet: Use correct company_id on timesheet analytic line
- When changing the project_id of an analytic line, the account_id is updated to the project's one, we need to update the company_id according the one set on project's analytic account.
This commit is contained in:
@@ -61,8 +61,10 @@ class Task(models.Model):
|
||||
# a timesheet must have an analytic account (and a project)
|
||||
if self and not project_id:
|
||||
raise UserError(_('This task must have a project since they are linked to timesheets.'))
|
||||
account_id = self.env['project.project'].browse(project_id).sudo().analytic_account_id
|
||||
self.sudo().mapped('timesheet_ids').write({
|
||||
'project_id': project_id,
|
||||
'account_id': self.env['project.project'].browse(project_id).sudo().analytic_account_id.id
|
||||
'account_id': account_id.id,
|
||||
'company_id': account_id.company_id.id,
|
||||
})
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user