[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: e890682656
opw:1868116
This commit is contained in:
@@ -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
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user