From b60be49a564554593595c85451a531fb811dc251 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 26 Apr 2021 12:09:48 +0000 Subject: [PATCH] [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#70086 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(-) diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index 5272f7cb22e..c2f511440bf 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -153,7 +153,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