[FIX] purchase: null stock_moves creation

When the quantity of a purchase order line is manually decreased and if
the purchase order line as been generated by more than one procurement.
If the new quantity is lower than the quantity of the smallest
procurement, it is impossible to validate the picking containg the
stock_moves created by the purchase order validation.

It is impossible to validate the picking, because it contains
stock_moves with 'product_qty' set to 0. Those stock_moves are generated
during the validation of a purchase order.

To fix this issue, we avoid the creation of stock moves with a
'product_qty' set to 0 which has no sense.
This commit is contained in:
Pierre Masereel
2017-01-18 11:45:26 +01:00
parent 3efc16e9a0
commit 1f6ec2b8d6
+1 -1
View File
@@ -645,7 +645,7 @@ class PurchaseOrderLine(models.Model):
sum_existing_moves = sum(x.product_qty for x in procurement.move_ids if x.state != 'cancel')
existing_proc_qty = procurement.product_id.uom_id._compute_quantity(sum_existing_moves, procurement.product_uom)
procurement_qty = procurement.product_uom._compute_quantity(procurement.product_qty, line.product_uom) - existing_proc_qty
if float_compare(procurement_qty, 0.0, precision_rounding=procurement.product_uom.rounding) > 0:
if float_compare(procurement_qty, 0.0, precision_rounding=procurement.product_uom.rounding) > 0 and float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0:
tmp = template.copy()
tmp.update({
'product_uom_qty': min(procurement_qty, diff_quantity),