Skip to content

Commit dbaf8da

Browse files
committed
[FIX] mrp: compare the quantities with float compare
Steps to reproduce the bug: - Go to decimal accuracy > product unit of measure - Change the Digits from 2 to 4 - Create a storable product “P1”: - Create a BoM: - Add 1 unit of a component - Create a MO: - Product : P1 - Qty to produce: 41,0654 - Confirm the MO - click on Action and try to split the MO in two: - MO_1: qty 35,9757 - MO_2: qty 5,0897 - Validate the split Problem: A user error is triggered, “Unable to split with more than the quantity to produce.” While (35,9757 + 5,0897) = 41,0654 we have to use `float_compare` to avoid this kind of error opw-3178441 closes odoo#114602 X-original-commit: 3889716 Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
1 parent f24a87b commit dbaf8da

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

addons/mrp/models/mrp_production.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,8 @@ def _default_amounts(production):
15711571
if total_amount < production.product_qty and not cancel_remaining_qty:
15721572
amounts[production].append(production.product_qty - total_amount)
15731573
has_backorder_to_ignore[production] = True
1574-
elif total_amount > production.product_qty or production.state in ['done', 'cancel']:
1574+
elif float_compare(total_amount, production.product_qty, precision_rounding=production.product_uom_id.rounding) > 0 \
1575+
or production.state in ['done', 'cancel']:
15751576
raise UserError(_("Unable to split with more than the quantity to produce."))
15761577

15771578
backorder_vals_list = []

0 commit comments

Comments
 (0)