From 602e0528cd5e1c051b7fe1aa2ae8041af7d30275 Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Tue, 4 Sep 2018 13:29:58 +0200 Subject: [PATCH] [FIX] hr_timesheet: generate AA when allowing timesheet During the super of write, a check constraint is done in python. So, if writing allow_timesheet=True the constraint will raise is no AA is set on the project. This commit restore the exepected behavior. --- addons/hr_timesheet/models/project.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index bb22610098b..9230cfb48f3 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -58,11 +58,12 @@ class Project(models.Model): @api.multi def write(self, values): - result = super(Project, self).write(values) # create the AA for project still allowing timesheet - for project in self: - if project.allow_timesheets and not project.analytic_account_id: - project._create_analytic_account() + if values.get('allow_timesheets'): + for project in self: + if not project.analytic_account_id and not values.get('analytic_account_id'): + project._create_analytic_account() + result = super(Project, self).write(values) return result @api.multi