diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index bfdc17f7d27..81895718a96 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -57,11 +57,15 @@ class AccountAnalyticLine(models.Model): @api.multi def write(self, values): # prevent to update invoiced timesheets if one line is of type delivery + self._check_can_write(values) + result = super(AccountAnalyticLine, self).write(values) + return result + + @api.multi + def _check_can_write(self, values): if self.sudo().filtered(lambda aal: aal.so_line.product_id.invoice_policy == "delivery") and self.filtered(lambda timesheet: timesheet.timesheet_invoice_id): if any([field_name in values for field_name in ['unit_amount', 'employee_id', 'project_id', 'task_id', 'so_line', 'amount', 'date']]): raise UserError(_('You can not modify already invoiced timesheets (linked to a Sales order items invoiced on Time and material).')) - result = super(AccountAnalyticLine, self).write(values) - return result @api.model def _timesheet_preprocess(self, values):