From 1924fb4bb95b7dd9ca25d55da56297084355a9c2 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 11 Aug 2016 11:54:40 +0200 Subject: [PATCH] [FIX] account: don't use abs price in invoice report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The field price_subtotal_signed on an invoice line contains the line subtotal: - untouched if the invoice is of in_refund or out_invoice type, - negated if the invoice is of in_invoice or out_refund type At one point in time (not found), commit 649b289f using absolute value of price_subtotal was introduced because price_subtotal_signed sometimes had the wrong sign. But this is source of an issue since it is possible to have an invoice with two lines such as : 100€ and -20€, the report would then display 120, whilst 80 should have appeared. This commit remove the use of absolute value, and if some old report data (pre saas-6 migration with wrong migration script) are reported wrong for an instance, it should be corrected manually. opw-683952 closes #13118 --- addons/account/report/account_invoice_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 70e79867d20..6c2cdcbbe35 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -114,7 +114,7 @@ class AccountInvoiceReport(models.Model): ai.type, ai.state, pt.categ_id, ai.date_due, ai.account_id, ail.account_id AS account_line_id, ai.partner_bank_id, SUM ((invoice_type.sign * ail.quantity) / (u.factor * u2.factor)) AS product_qty, - SUM(invoice_type.sign * ABS(ail.price_subtotal_signed)) AS price_total, + SUM(ail.price_subtotal_signed) AS price_total, SUM(ABS(ail.price_subtotal_signed)) / CASE WHEN SUM(ail.quantity / u.factor * u2.factor) <> 0::numeric THEN SUM(ail.quantity / u.factor * u2.factor)