diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 64a6f3f4902..012da289c02 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -115,11 +115,17 @@ class AccountInvoiceReport(models.Model): THEN (- ail.quantity) / u.factor * u2.factor ELSE ail.quantity / u.factor * u2.factor END) AS product_qty, - SUM(ABS(ail.price_subtotal_signed) * CASE - WHEN ai.type::text = ANY (ARRAY['out_refund'::character varying::text, 'in_invoice'::character varying::text]) - THEN -1 - ELSE 1 - END + SUM(ABS(ail.price_subtotal_signed) + * CASE + WHEN ail.price_subtotal < 0 + THEN -1 + ELSE 1 + END + * CASE + WHEN ai.type::text = ANY (ARRAY['out_refund'::character varying::text, 'in_invoice'::character varying::text]) + THEN -1 + ELSE 1 + END ) AS price_total, SUM(ABS(ail.price_subtotal_signed)) / CASE WHEN SUM(ail.quantity / u.factor * u2.factor) <> 0::numeric