[FIX] account: account_invoice_report: make the calculation of product_qty right

Before this commit product quantity was computed as if the uom on the product represented the *unit* in which a product was sold
Hence, in the report, it produced something like this:
I sell 10 packages of something, which is sold essentially by 10 itself = which makes a total unitary quantity of 100
This wrong behavior has been introduced in 10.0 by 9c5d4cd60c

After this commit, the computation is done to match the *standard* unit of measure in which a product quantity is *represented*

OPW 741745

Closes #16834
This commit is contained in:
Lucas Perais (lpe)
2017-05-08 14:18:02 +02:00
parent 20facf5cf9
commit 6513658957
@@ -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 * ail.quantity) / u.factor * u2.factor) AS product_qty,
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