From a2456b20e9af30b0bf429302faf8291416ca3f0e Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Tue, 18 Sep 2018 16:24:36 +0200 Subject: [PATCH] [FIX] hr_timesheet: create project with allow_timesheet checked by default The default value when creating a project is true for 'allow_timesheet' field. This will automatically create an Analytic Account (if not provided). However, the old onchange reset the allow_timesheet to false if no AA was given, which is a contraction with the expected behavior on project creation. But, we might want to uncheck 'allow_timesheet' when we remove the AA on an existing project (Users can not log timesheets without an active analytic account). This commit fixes the erasing default value on creation by checking the record is currently existing in the database. Task #1886691 --- addons/hr_timesheet/models/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index 9230cfb48f3..e34f395b87b 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -22,7 +22,7 @@ class Project(models.Model): @api.onchange('analytic_account_id') def _onchange_analytic_account(self): - if not self.analytic_account_id: + if not self.analytic_account_id and self._origin: self.allow_timesheets = False @api.constrains('allow_timesheets', 'analytic_account_id')