[FIX] purchase: Purchase report wrong qty_to_be_billed

Steps to reproduce the bug:
- Let's consider product P with purchase_method = 'purchase'
- Create a purchase order PO and puchase 20 units of P to a vendor
- Confirm PO and create a vendor bill VB the 20 units of P
- Validate VB
- The invoiced quantity on PO is 20
- Go to the Purchase report and analyse the qty_to_be_billed

Bug:

The qty_to_be_billed was still equal to 20 instead of 0

opw:2091264

closes odoo/odoo#39493

X-original-commit: b00febedef7826f593bb07c7896595ecce8cae32
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2019-10-29 10:08:49 +00:00
committed by fw-bot
parent 5ce1b759ca
commit 3ba8231733
+5 -1
View File
@@ -92,7 +92,10 @@ class PurchaseReport(models.Model):
sum(l.product_qty / line_uom.factor * product_uom.factor) as qty_ordered,
sum(l.qty_received / line_uom.factor * product_uom.factor) as qty_received,
sum(l.qty_invoiced / line_uom.factor * product_uom.factor) as qty_billed,
sum(l.product_qty / line_uom.factor * product_uom.factor) - sum(l.qty_received / line_uom.factor * product_uom.factor) as qty_to_be_billed
case when t.purchase_method = 'purchase'
then sum(l.product_qty / line_uom.factor * product_uom.factor) - sum(l.qty_invoiced / line_uom.factor * product_uom.factor)
else sum(l.qty_received / line_uom.factor * product_uom.factor) - sum(l.qty_invoiced / line_uom.factor * product_uom.factor)
end as qty_to_be_billed
""" % self.env['res.currency']._select_companies_rates()
return select_str
@@ -135,6 +138,7 @@ class PurchaseReport(models.Model):
line_uom.uom_type,
line_uom.category_id,
t.uom_id,
t.purchase_method,
line_uom.id,
product_uom.factor,
partner.country_id,