From 42bbe463c09697c45a9751861f14aa3dde7aa3fa Mon Sep 17 00:00:00 2001 From: "Mathias Mathy (MAMA)" Date: Wed, 31 May 2023 10:58:42 +0000 Subject: [PATCH] [FIX] stock,mrp: Wrong forecasting on widget **Summary :** When using a great decimal precision, forecast_widget shows red neverthless the available quantity is sufficient. **Steps to reproduce :** - In Settings >> Technical >> Database Structure >> Decimal Accuracy - For usage __Product Unit of Measure__, set __Digits__ to **__6__** - Create products of type storable : - __Test Component__ with a __Qty on hand__ of **__76.6__** Units - __Test Product__ - Create a BoM for __Test Product__, with Quantity set to **__1__** Units - Add component __Test Component__ with Quantity set to **__15.32__** Units - Create a MO for BoM __Test Product__ with a Quantity set to **__5__** Units - Confirm the MO. **Before :** Neverthless the __To Consume__ qty is set to 76.6, which is equal to the __Qty on hand__ of the component, the forecast widget shows red as if there's an insufficient quantity of the component **After :** With help of the Odoo's __formatFloat__ method, we round the data used in the comparison defining the __willBeFulfilled__. The forecast_widget now display properly, taking into account the digit precision setup in the database. opw-3281588 closes odoo/odoo#123388 X-original-commit: 0d4b95e9d9d2218d6d9165f082e9f59d5025262d Signed-off-by: Tiffany Chang --- addons/stock/static/src/widgets/forecast_widget.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/static/src/widgets/forecast_widget.js b/addons/stock/static/src/widgets/forecast_widget.js index 379b8417856..f5bfbedae17 100644 --- a/addons/stock/static/src/widgets/forecast_widget.js +++ b/addons/stock/static/src/widgets/forecast_widget.js @@ -24,7 +24,8 @@ export class ForecastWidgetField extends FloatField { if (data.forecast_expected_date && data.date_deadline) { this.forecastIsLate = data.forecast_expected_date > data.date_deadline; } - this.willBeFulfilled = data.forecast_availability >= data.product_qty; + const digits = fields.forecast_availability.digits; + this.willBeFulfilled = parseFloat(formatFloat(data.forecast_availability, {"digits" : digits})) >= parseFloat(formatFloat(data.product_qty, {"digits" : digits})); this.state = data.state; }