[FIX] hr_expense: multiple payment modes

- Create an expense paid by employee
- Create an expense paid by company
- Select the two expenses and submit a report

You are authorized to create this report but you cannot validate it and
you cannot refuse it because of the mix of an expense paid by employee
and paid by company. You're blocked.

We should block the creation of an expense report mixing expenses paid
by company and paid by employee

opw-783395
This commit is contained in:
Nicolas Martinelli
2017-11-21 14:19:13 +01:00
committed by Nicolas Martinelli
parent 5e038eedeb
commit f075b52a25
2 changed files with 31 additions and 1 deletions
+24 -1
View File
@@ -148,6 +148,11 @@ msgstr ""
msgid "All Expenses"
msgstr ""
#. module: hr_expense
#: model:ir.model.fields,help:hr_expense.field_hr_expense_account_id
msgid "An expense account is expected"
msgstr ""
#. module: hr_expense
#: model:ir.model.fields,field_description:hr_expense.field_hr_expense_analytic_account_id
#: model:ir.ui.view,arch_db:hr_expense.view_hr_expense_filter
@@ -826,6 +831,18 @@ msgid "Once your email gateway is configured, come back to this screen\n"
" to setup the next steps."
msgstr ""
#. module: hr_expense
#: code:addons/hr_expense/models/hr_expense.py:537
#, python-format
msgid "Only HR Officers can approve expenses"
msgstr ""
#. module: hr_expense
#: code:addons/hr_expense/models/hr_expense.py:528
#, python-format
msgid "Only HR Officers can refuse expenses"
msgstr ""
#. module: hr_expense
#: selection:hr.expense.sheet,state:0
#: model:mail.message.subtype,name:hr_expense.mt_expense_paid
@@ -1308,7 +1325,13 @@ msgid "You cannot report expenses for different employees in the same report!"
msgstr ""
#. module: hr_expense
#: code:addons/hr_expense/models/hr_expense.py:104
#: code:addons/hr_expense/models/hr_expense.py:605
#, python-format
msgid "You cannot report expenses with different payment modes."
msgstr ""
#. module: hr_expense
#: code:addons/hr_expense/models/hr_expense.py:105
#, python-format
msgid "You cannot report twice the same line!"
msgstr ""
+7
View File
@@ -596,3 +596,10 @@ class HrExpenseSheet(models.Model):
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.'))
@api.one
@api.constrains('expense_line_ids')
def _check_payment_mode(self):
payment_mode = set(self.expense_line_ids.mapped('payment_mode'))
if len(payment_mode) > 1:
raise ValidationError(_('You cannot report expenses with different payment modes.'))