From 412892ceaffbd6e3d6386eea434ccf63b7bf755b Mon Sep 17 00:00:00 2001 From: Toufik Benjaa Date: Wed, 16 May 2018 17:41:15 +0200 Subject: [PATCH] [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. --- addons/hr_timesheet/models/project.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index 72a88277886..c88aa12c864 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -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