[FIX] hr_expense: display expenses amounts to be paid
Steps to reproduce: - create-aprove-post an expense - Go to the accounting dashboard Issue: expenses' amount is 0 Cause: In `_count_results_and_sum_amounts`, since the expense.currency is the same as the company we don't get the correct result: https://github.com/odoo/odoo/blob/d29a622740f6c34d25c52add5367bfdf58bbaf49/addons/account/models/account_journal_dashboard.py#L641-L644 Solution: Get the right columns. We also change the domain to make sure that expenses partially paid are also displayed. Note: For the test we check that even partially paid expenses are displayed. In Master we want the residual amount to be displayed. In master: Use the amount_residual (discussed with po Laura) opw-3849036 closes odoo/odoo#162182 Signed-off-by: John Laterre (jol) <jol@odoo.com>
This commit is contained in:
@@ -9,8 +9,12 @@ class AccountJournal(models.Model):
|
||||
|
||||
def _prepare_expense_sheet_data_domain(self):
|
||||
return [
|
||||
('state', '=', 'post'),
|
||||
('journal_id', 'in', self.ids),
|
||||
'|',
|
||||
('state', '=', 'post'),
|
||||
'&',
|
||||
('state', '=', 'done'),
|
||||
('payment_state', '=', 'partial'),
|
||||
]
|
||||
|
||||
def _get_expense_to_pay_query(self):
|
||||
@@ -23,7 +27,8 @@ class AccountJournal(models.Model):
|
||||
return
|
||||
field_list = [
|
||||
"hr_expense_sheet.journal_id",
|
||||
"hr_expense_sheet.total_amount AS amount_total",
|
||||
# todo master: "hr_expense_sheet.amount_residual AS amount_total_company",
|
||||
"hr_expense_sheet.total_amount AS amount_total_company",
|
||||
"hr_expense_sheet.currency_id AS currency",
|
||||
]
|
||||
query, params = sale_purchase_journals._get_expense_to_pay_query().select(*field_list)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import common
|
||||
from . import test_account_journal_dashboard
|
||||
from . import test_expenses
|
||||
from . import test_expenses_access_rights
|
||||
from . import test_expenses_mail_import
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
from odoo.tools.misc import format_amount
|
||||
|
||||
from odoo.addons.hr_expense.tests.common import TestExpenseCommon
|
||||
from odoo.tests import tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestAccountJournalDashboard(TestExpenseCommon):
|
||||
|
||||
def test_expense_journal_numbers_and_sums(self):
|
||||
journal = self.company_data['default_journal_purchase']
|
||||
company_currency = self.env.company.currency_id
|
||||
expense_sheet = self.create_expense_report()
|
||||
expense_sheet.action_submit_sheet()
|
||||
expense_sheet.action_approve_expense_sheets()
|
||||
expense_sheet.action_sheet_move_create()
|
||||
|
||||
expense_sheet.flush_recordset()
|
||||
dashboard_data = journal._get_journal_dashboard_data_batched()[journal.id]
|
||||
self.assertEqual(dashboard_data['sum_expenses_to_pay'], format_amount(self.env, 1000, company_currency))
|
||||
|
||||
payment = self.get_new_payment(expense_sheet, 250.0)
|
||||
expense_sheet.flush_recordset()
|
||||
payment.flush_recordset()
|
||||
dashboard_data = journal._get_journal_dashboard_data_batched()[journal.id]
|
||||
# todo master: have 750 (residual amount will be used)
|
||||
# we still want to assert a second time in order to make sure that partially paid expenses are displayed
|
||||
self.assertEqual(dashboard_data['sum_expenses_to_pay'], format_amount(self.env, 1000, company_currency))
|
||||
Reference in New Issue
Block a user