From cd2e8e589d41cef1906cbb2899bed0a748ab5f9d Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Wed, 22 Feb 2023 09:02:00 +0000 Subject: [PATCH] [FIX] mrp: rounding total amounts before splitting closes odoo/odoo#115467 X-original-commit: e5ff98655a21366d49f44c7b4374f8a04b72cd70 Signed-off-by: William Henrotin (whe) --- addons/mrp/models/mrp_production.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 5cdc55888ad..dee698355d1 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1552,11 +1552,11 @@ class MrpProduction(models.Model): amounts[production] = _default_amounts(production) continue total_amount = sum(mo_amounts) - if total_amount < production.product_qty and not cancel_remaining_qty: + diff = float_compare(production.product_qty, total_amount, precision_rounding=production.product_uom_id.rounding) + if diff > 0 and not cancel_remaining_qty: amounts[production].append(production.product_qty - total_amount) has_backorder_to_ignore[production] = True - elif float_compare(total_amount, production.product_qty, precision_rounding=production.product_uom_id.rounding) > 0 \ - or production.state in ['done', 'cancel']: + elif diff < 0 or production.state in ['done', 'cancel']: raise UserError(_("Unable to split with more than the quantity to produce.")) backorder_vals_list = []