[FIX] purchase: billed qty

In a SO, the "Invoiced Qty" can decrease if the refund is generated from
the SO. It doesn't decrease if the refund is generated from the Invoice.
However, we don't have this mechanism in a PO since the invoice is not
generated directly from the PO. There is therefore no way to decrease
the "Billed Qty".

We authorize the "Billed Qty" to decrease in the case of PO.

Complement of commit 9b5281adb4

opw-724474
This commit is contained in:
Nicolas Martinelli
2017-03-22 10:43:04 +01:00
parent ffaa65833d
commit c6a7e4fbb9
+5 -2
View File
@@ -525,8 +525,11 @@ class PurchaseOrderLine(models.Model):
for line in self:
qty = 0.0
for inv_line in line.invoice_lines:
if inv_line.invoice_id.state not in ['cancel'] and inv_line.invoice_id.type == 'in_invoice':
qty += inv_line.uom_id._compute_quantity(inv_line.quantity, line.product_uom)
if inv_line.invoice_id.state not in ['cancel']:
if inv_line.invoice_id.type == 'in_invoice':
qty += inv_line.uom_id._compute_quantity(inv_line.quantity, line.product_uom)
elif inv_line.invoice_id.type == 'in_refund':
qty -= inv_line.uom_id._compute_quantity(inv_line.quantity, line.product_uom)
line.qty_invoiced = qty
@api.depends('order_id.state', 'move_ids.state')