From 44693ca2689d736849d708aa9bf917db65c4b8a0 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 26 Apr 2021 12:09:48 +0000 Subject: [FIX] hr_timesheet: Analytic account without company Steps to reproduce the bug: - Let's consider a project P set with analytic account AA and company C - Allow timesheet on P - Let's consider a task T belonging to P - Set AA with comapny = False - Try to encode a timesheet on T Bug: A UserError was raised because the field company_id on account.analytic.line is required opw:2486034 closes odoo/odoo#70071 X-original-commit: b3dc922cb45bdd4c2778bea784b540b1723c8fc1 Signed-off-by: Simon Goffin (sig) --- addons/hr_timesheet/models/hr_timesheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons') diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index 17d4a613371..a074961e95f 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -152,7 +152,7 @@ class AccountAnalyticLine(models.Model): if vals.get('project_id') and not vals.get('account_id'): project = self.env['project.project'].browse(vals.get('project_id')) vals['account_id'] = project.analytic_account_id.id - vals['company_id'] = project.analytic_account_id.company_id.id + vals['company_id'] = project.analytic_account_id.company_id.id or project.company_id.id if not project.analytic_account_id.active: raise UserError(_('The project you are timesheeting on is not linked to an active analytic account. Set one on the project configuration.')) # employee implies user -- cgit v1.2.3