From 1f6ec2b8d65279ca6a5259ee91d098dc4d1a71f2 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Tue, 17 Jan 2017 16:18:16 +0100 Subject: [PATCH] [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. --- addons/purchase/models/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index d41d8f62c33..a5079ba1eff 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -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),