[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) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2021-04-29 09:40:05 +00:00
parent 6ee928bd30
commit b60be49a56
+1 -1
View File
@@ -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