[FIX] stock: use float_compare to avoid an error in the transfer (The roundings of your Unit of Measures kg on the move vs. kg on the product don't allow to do these operations or you are not transferring the picking at once.)

This commit is contained in:
Alexis de Lattre 2016-06-13 22:23:26 +02:00 committed by Josse Colpaert
parent ff93777099
commit 297bbff6f5
1 changed files with 3 additions and 2 deletions

View File

@ -1303,10 +1303,11 @@ class stock_picking(osv.osv):
elif ops.product_id.id:
#Check moves with same product
qty_to_assign = uom_obj._compute_qty_obj(cr, uid, ops.product_uom_id, ops.product_qty, ops.product_id.uom_id, context=context)
precision_rounding = ops.product_id.uom_id.rounding
for move_dict in prod2move_ids.get(ops.product_id.id, []):
move = move_dict['move']
for quant in move.reserved_quant_ids:
if not qty_to_assign > 0:
if float_compare(qty_to_assign, 0, precision_rounding=precision_rounding) != 1:
break
if quant.id in quants_in_package_done:
continue
@ -1322,7 +1323,7 @@ class stock_picking(osv.osv):
max_qty_on_link = min(quant.qty, qty_to_assign)
qty_on_link = _create_link_for_quant(ops.id, quant, max_qty_on_link)
qty_to_assign -= qty_on_link
qty_assign_cmp = float_compare(qty_to_assign, 0, precision_rounding=ops.product_id.uom_id.rounding)
qty_assign_cmp = float_compare(qty_to_assign, 0, precision_rounding=precision_rounding)
if qty_assign_cmp > 0:
#qty reserved is less than qty put in operations. We need to create a link but it's deferred after we processed
#all the quants (because they leave no choice on their related move and needs to be processed with higher priority)