From d93c4bef1daa61a54a0305203bf8f7de950b835d Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 9 Mar 2015 11:46:36 +0100 Subject: [PATCH] [FIX] mrp: always use float_compare to compare floats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When comparing a float value to 0.0, it can happen the float value is very near to 0.0, but not exactly 0. This is the point to use float_compare, ```float_compare(qty, 0, self.pool['decimal.precision'].precision_get(cr, uid, 'Product Unit of Measure'))ยดยดยด will compare qty to 0, with the product unit of measure precision (0.01 by default). So, if qty is equal to 0.00001, this means the qty is regarded as equal to 0.0. (float_compare will return 1). --- addons/mrp/mrp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index b9529b31638..770957c0b81 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -887,7 +887,7 @@ class mrp_production(osv.osv): else: dicts[product_id][lot_id] = quant_qty qty -= quant_qty - if qty > 0: + if float_compare(qty, 0, self.pool['decimal.precision'].precision_get(cr, uid, 'Product Unit of Measure')) == 1: if dicts[product_id].get(False): dicts[product_id][False] += qty else: