From 43d539dc5ab3019dac06309075e1fd2e9915d07f Mon Sep 17 00:00:00 2001 From: nouraellm Date: Mon, 3 May 2021 21:11:55 +0000 Subject: [PATCH] [FIX] stock, mrp: Fix precision overflow in forecasted report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix tends to prevent precision overflow in forecasted report Current behavior before PR: - If there are 2 units in stock and product_uom_qty is set to 0.66 the free_stock will be equal to 1.3399999999999999 Desired behavior after PR is merged: - If there are 2 units in stock and product_uom_qty is set to 0.66 the free_stock should be equal to 1.34 opw-2425473 opw-2459650 opw-2448443 opw-2446985 opw-2440853 opw-2464507 closes odoo/odoo#70321 X-original-commit: c69fb8ec6828676a1900c56f1e87df809b6b70c2 Signed-off-by: Rémy Voet --- addons/stock/report/report_stock_forecasted.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/report/report_stock_forecasted.py b/addons/stock/report/report_stock_forecasted.py index cdbdc21e4bc..65b2e1b2912 100644 --- a/addons/stock/report/report_stock_forecasted.py +++ b/addons/stock/report/report_stock_forecasted.py @@ -4,7 +4,7 @@ from collections import defaultdict from odoo import api, models -from odoo.tools import float_is_zero, format_datetime, format_date +from odoo.tools import float_is_zero, format_date, float_round class ReplenishmentReport(models.AbstractModel): @@ -127,7 +127,7 @@ class ReplenishmentReport(models.AbstractModel): 'receipt_date': format_date(self.env, move_in.date) if move_in else False, 'delivery_date': format_date(self.env, move_out.date) if move_out else False, 'is_late': is_late, - 'quantity': quantity, + 'quantity': float_round(quantity, precision_rounding=product.uom_id.rounding), 'move_out': move_out, 'move_in': move_in, 'reservation': reservation,