From b6eef3eeccba57699818325fd03d66bc8c7dfdbc Mon Sep 17 00:00:00 2001 From: "Piero (pca)" Date: Wed, 11 May 2022 19:14:45 +0000 Subject: [PATCH] [FIX] stock: correct float compare to use proper product This commit will correct the precision_rounding parameter in the float_compare call to use the current move's product. Previously, this was using the product_id variable from a previous for loop. An issue is caused when a transfer is created from `mts_else_mto` procure methods in stock.rule records. When the '_adjust_procure_method' hits a rule with this procure method, it reaches the 'mtso_moves' for loop. The needed quantity and forecasted quantity will be compared to decide whether a stock.move record is needed to fulfill the needed amount. The problem is that the 'float_compare' method is using 'product_id' to set its precision_rounding method. The 'product_id' variable is only accessed in the prior for-loop and will always reference the final product iterated. As a result, any case where there are product quantities smaller than the final product's UoM, it is skipped. opw-2820401 closes odoo/odoo#91361 X-original-commit: 892232b5aef42dd2706cb9d1d027b1c463ca50dd Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 740804e8caa..e6f9ec09b34 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -1925,7 +1925,7 @@ class StockMove(models.Model): for move in mtso_moves: needed_qty = move.product_qty forecasted_qty = mtso_free_qties_by_loc[move.location_id][move.product_id.id] - if float_compare(needed_qty, forecasted_qty, precision_rounding=product_id.uom_id.rounding) <= 0: + if float_compare(needed_qty, forecasted_qty, precision_rounding=move.product_uom.rounding) <= 0: move.procure_method = 'make_to_stock' mtso_free_qties_by_loc[move.location_id][move.product_id.id] -= needed_qty else: