[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.
This commit is contained in:
jem-odoo
2018-09-07 14:06:48 +02:00
parent 3444e0a0da
commit 602e0528cd
+5 -4
View File
@@ -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