[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.
This commit is contained in:
Stéphane Bidoul (ACSONE)
2017-12-18 12:32:17 +01:00
committed by Yannick Tivisse
parent 052323fae4
commit 5377f7b85c
+1 -1
View File
@@ -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):