diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index e9e960872fd..3ef358a9093 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -98,7 +98,27 @@ class AccountInvoiceReport(models.Model): move.invoice_payment_term_id, move.invoice_partner_bank_id, move.amount_residual_signed AS residual, - move.amount_total_signed AS amount_total, + ROUND( + line.price_total / COALESCE( + (SELECT rate FROM res_currency_rate cr WHERE + cr.currency_id = line.currency_id AND + cr.company_id = line.company_id AND + cr.name <= COALESCE(line.date,NOW()) + ORDER BY cr.name DESC + LIMIT 1) + ,1), + COALESCE((SELECT decimal_places + FROM res_currency rc INNER JOIN res_currency_rate cr ON + rc.id = cr.currency_id + WHERE cr.currency_id = (COALESCE(line.currency_id, line.company_currency_id)) AND + cr.company_id = line.company_id + LIMIT 1 + ),2)) + * + (CASE WHEN move.amount_total_signed < 0 + THEN -1 + ELSE 1 + END) AS amount_total, uom_template.id AS product_uom_id, template.categ_id AS product_categ_id, SUM(line.quantity / NULLIF(COALESCE(uom_line.factor, 1) * COALESCE(uom_template.factor, 1), 0.0)) diff --git a/addons/account/tests/test_account_invoice_report.py b/addons/account/tests/test_account_invoice_report.py index bc4d6e2e27b..a794b2a4b6b 100644 --- a/addons/account/tests/test_account_invoice_report.py +++ b/addons/account/tests/test_account_invoice_report.py @@ -114,8 +114,8 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon): self.assertInvoiceReportValues([ # amount_total price_average price_subtotal residual quantity [2000, 2000, 2000, 2000, 1], - [2000, 1000, 1000, 2000, 1], - [2000, 1000, 1000, 2000, 3], + [1000, 1000, 1000, 2000, 1], + [1000, 1000, 1000, 2000, 3], [6, 6, 6, 6, 1], [-20, -20, -20, -20, 1], [-20, -20, -20, -20, 1],