[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 <arm@odoo.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user