Skip to content

Commit

Permalink
[FIX] hr_expense: employee on expense
Browse files Browse the repository at this point in the history
The employee of the expense report should be the same than the employee
on expense lines.

opw-740646
  • Loading branch information
nim-odoo committed Apr 27, 2017
1 parent c242526 commit 7413b26
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/hr_expense/models/hr_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,10 @@ def _check_amounts(self):
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 comments on commit 7413b26

Please sign in to comment.