From bf35fd86d0de164ed98cae1b66e25144e4f3348f Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Tue, 7 Dec 2021 14:13:40 +0000 Subject: [PATCH] [FIX] stock: correctly compare float Due to floating point representation, some floats may have some insignificant decimals. Therefore, `float_compare` should be used when comparing such numbers OPW-2699576 closes odoo/odoo#81138 X-original-commit: 7f30ef42717b009ee569db58b885ce863d969a06 Signed-off-by: William Henrotin (whe) Signed-off-by: Adrien Widart --- addons/stock/models/stock_move.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index d283b8a9ee0..12a60569086 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -1743,11 +1743,12 @@ class StockMove(models.Model): def _recompute_state(self): moves_state_to_write = defaultdict(set) for move in self: + rounding = move.product_uom.rounding if move.state in ('cancel', 'done', 'draft'): continue - elif move.reserved_availability == move.product_uom_qty: + elif float_compare(move.reserved_availability, move.product_uom_qty, precision_rounding=rounding) == 0: moves_state_to_write['assigned'].add(move.id) - elif move.reserved_availability and move.reserved_availability <= move.product_uom_qty: + elif move.reserved_availability and float_compare(move.reserved_availability, move.product_uom_qty, precision_rounding=rounding) <= 0: moves_state_to_write['partially_available'].add(move.id) elif move.procure_method == 'make_to_order' and not move.move_orig_ids: moves_state_to_write['waiting'].add(move.id)