From 40507c4ad9edbbd99e9461b966b3d676c83502a6 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 15 Feb 2017 14:10:33 +0100 Subject: [PATCH] [FIX] purchase: null stock_moves creation Backport of 1f6ec2b8d65279ca6a5259ee91d098dc4d1a71f2 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. opw:708099 --- addons/purchase/purchase.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 89e7e10b812..f7edbb994b2 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -609,15 +609,16 @@ class PurchaseOrderLine(models.Model): diff_quantity = line.product_qty for procurement in line.procurement_ids: procurement_qty = procurement.product_uom._compute_qty_obj(procurement.product_uom, procurement.product_qty, line.product_uom) - tmp = template.copy() - tmp.update({ - 'product_uom_qty': min(procurement_qty, diff_quantity), - 'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination - 'procurement_id': procurement.id, - 'propagate': procurement.rule_id.propagate, - }) - done += moves.create(tmp) - diff_quantity -= min(procurement_qty, diff_quantity) + if 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), + 'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination + 'procurement_id': procurement.id, + 'propagate': procurement.rule_id.propagate, + }) + done += moves.create(tmp) + diff_quantity -= min(procurement_qty, diff_quantity) if float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0: template['product_uom_qty'] = diff_quantity done += moves.create(template)