From 7b87212ea851518a641f65a71dc094cf88507cdc Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 29 Aug 2018 13:02:59 +0200 Subject: [PATCH] [FIX] account: Wrong quantity in Invoices analysis Steps to reproduce: Create a customer invoice with 2 product A and refund 1 product A. Display account.invoice.report for this custumer. Bug: The quantity should be 1 not 3. Fine tuning of this commit: e890682656b4739f489d34b954a1b1e8d9f78065 opw:1868116 --- addons/account/report/account_invoice_report.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 7c6bf726a38..77d026ed6ff 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -113,7 +113,7 @@ class AccountInvoiceReport(models.Model): 1 AS nbr, 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_qty * ail.quantity) / u.factor * u2.factor) AS product_qty, SUM(ail.price_subtotal_signed * invoice_type.sign) AS price_total, SUM(ABS(ail.price_subtotal_signed)) / CASE WHEN SUM(ail.quantity / u.factor * u2.factor) <> 0::numeric @@ -144,7 +144,11 @@ class AccountInvoiceReport(models.Model): WHEN ai.type::text = ANY (ARRAY['in_refund'::character varying::text, 'in_invoice'::character varying::text]) THEN -1 ELSE 1 - END) AS sign + END) AS sign,(CASE + WHEN ai.type::text = ANY (ARRAY['out_refund'::character varying::text, 'in_invoice'::character varying::text]) + THEN -1 + ELSE 1 + END) AS sign_qty FROM account_invoice ai ) AS invoice_type ON invoice_type.id = ai.id """