[FIX] Correct floating number handling for _procure_orderpoint_confirm
Fixes comparison with min_quantity orderpoint in scheduler - basic floating point math issue in procurement scheduler when comparing current quantity with orderpoint minimum quantity. In certain cases floating point comparison could result in e.g 400.0 < 400.0 == True due to typical floating point comparison issues, as Odoo doesn't use Decimal types where the issue doesn't exist. Fixes early exiting out of the loop cycle, in case qty is already near zero. Fixes the new procurement creation check, to not do that if it's close enough to zero already, to be considered a floating point math error, not really non-zero. These combined (or at least the last one) avoid each supply_method == buy pending in draft PO's getting a zero quantity extra procurement order each time the scheduler runs. Otherwise there could be hundreds of zero quantity procurement orders pending, which makes the confirming of the PO take hours, due to creating hundreds of stock moves for each order line. Use float_compare helper to solve all these with floating point type for now, instead of the more evasion possibility of converting to Decimal module. Two potential bad comparisons remain, add FIXME notes for now until further analysis. Also: Float rounding on reste when comparing and on the procurement qty
Please register or sign in to comment