From 5377f7b85c7b02904e26a5d64c7145b4b8fec595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Sat, 12 Aug 2017 16:23:40 +0200 Subject: [PATCH] [FIX] hr_expense: Make _check_employee dependent on employee_id Purpose ======= Employee must match on sheet and lines Since the employee_id field of hr.expense.sheet is modifiable in submit state, there is a possibility to modify a sheet in such a way that the employee does not match on the expense sheet and expense lines. This commit fixes this. --- addons/hr_expense/models/hr_expense.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 4bbdb0b3dbc..2ba4256b639 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -591,7 +591,7 @@ class HrExpenseSheet(models.Model): raise ValidationError(_('You cannot have a positive and negative amounts on the same expense report.')) @api.one - @api.constrains('expense_line_ids') + @api.constrains('expense_line_ids', 'employee_id') def _check_employee(self): employee_ids = self.expense_line_ids.mapped('employee_id') if len(employee_ids) > 1 or (len(employee_ids) == 1 and employee_ids != self.employee_id):