Skip to content
Snippets Groups Projects
Commit 7413b262 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] hr_expense: employee on expense

The employee of the expense report should be the same than the employee
on expense lines.

opw-740646
parent c242526b
No related branches found
No related tags found
No related merge requests found
......@@ -554,3 +554,10 @@ class HrExpenseSheet(models.Model):
negative_lines = any([l.total_amount < 0 for l in self.expense_line_ids])
if positive_lines and negative_lines:
raise ValidationError(_('You cannot have a positive and negative amounts on the same expense report.'))
@api.one
@api.constrains('expense_line_ids')
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):
raise ValidationError(_('You cannot add expense lines of another employee.'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment