[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) <whe@odoo.com> Signed-off-by: Adrien Widart <awt@odoo.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user