diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index ac69306562b..6dcbfe88c28 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -905,13 +905,11 @@ class HrExpense(models.Model): ('employee_id', 'in', self.env.user.employee_ids.ids), '|', '&', ('payment_mode', 'in', ('own_account', 'company_account')), ('state', 'in', ('draft', 'reported', 'submitted')), '&', ('payment_mode', '=', 'own_account'), ('state', '=', 'approved') - ], ['state', 'currency_id'], ['total_amount_currency:sum']) - for state, currency, total_amount_sum in expenses: + ], ['state'], ['total_amount:sum']) + for state, total_amount_sum in expenses: if state in {'draft', 'reported'}: # Fuse the two states into only one "To Submit" state state = 'to_submit' - currency = currency or target_currency - amount = currency._convert(total_amount_sum, target_currency, self.env.company, fields.Date.today()) - expense_state[state]['amount'] += amount + expense_state[state]['amount'] += total_amount_sum return expense_state # ---------------------------------------- diff --git a/addons/hr_expense/tests/test_expenses.py b/addons/hr_expense/tests/test_expenses.py index 5bb1b4f388c..7bddfa4cdcd 100644 --- a/addons/hr_expense/tests/test_expenses.py +++ b/addons/hr_expense/tests/test_expenses.py @@ -965,3 +965,22 @@ class TestExpenses(TestExpenseCommon): {'name': 'test sheet no update', 'price_unit': 100.0, 'quantity': 1, 'total_amount': 100.0}, {'name': 'test sheet update', 'price_unit': 250.0, 'quantity': 1, 'total_amount': 250.0}, # no update ]) + + def test_foreign_currencies_total(self): + Expense = self.env['hr.expense'].with_user(self.expense_user_employee) + Expense.create([{ + 'name': 'Company expense', + 'payment_mode': 'company_account', + 'total_amount_currency': 1000.00, + 'employee_id': self.expense_employee.id, + }, + { + 'name': 'Company expense 2', + 'payment_mode': 'company_account', + 'currency_id': self.currency_data['currency'].id, + 'total_amount_currency': 1000.00, + 'total_amount': 2000.00, + 'employee_id': self.expense_employee.id, + }]) + expense_state = Expense.get_expense_dashboard() + self.assertEqual(expense_state['to_submit']['amount'], 3000.00)