[FIX] account: invoice analysis total always positive

Create a Credit Note, save and confirm
Go to Reporting>Invoice Analysis
Switch to Pivot view, add mesures ntaxed Total and Total, expand rows by Move.

The credit note untaxed total is correctly reported as negative, total
is reported as positive

opw-3223043

closes odoo/odoo#116421

X-original-commit: 06b1f3d0c78fc22250fc544b4c3152a58bfbe05c
Signed-off-by: John Laterre (jol) <jol@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2023-03-24 11:08:27 +01:00
parent c4b4c4e621
commit e1b3f32d11
@@ -98,7 +98,8 @@ class AccountInvoiceReport(models.Model):
line.quantity / NULLIF(COALESCE(uom_line.factor, 1) / COALESCE(uom_template.factor, 1), 0.0) * (CASE WHEN move.move_type IN ('in_invoice','out_refund','in_receipt') THEN -1 ELSE 1 END)
AS quantity,
-line.balance * currency_table.rate AS price_subtotal,
line.price_total,
line.price_total * (CASE WHEN move.move_type IN ('in_invoice','out_refund','in_receipt') THEN -1 ELSE 1 END)
AS price_total,
-COALESCE(
-- Average line price
(line.balance / NULLIF(line.quantity, 0.0)) * (CASE WHEN move.move_type IN ('in_invoice','out_refund','in_receipt') THEN -1 ELSE 1 END)