From 7a979b2d3e4dd012f129ca2911648ef33338323b Mon Sep 17 00:00:00 2001
From: Mart Raudsepp <mart@povi.ee>
Date: Tue, 2 Dec 2014 13:26:17 +0000
Subject: [PATCH] [FIX] Fix floating point handling in purchase
 _prepare_order_line_move

Without this better floating point handling, an extra stock move might
be created for zero quantity for some order lines upon PO confirmation,
because qty is equal to something closer to e.g 1.14e-13, but this is
larger than 0, so it creates a stock.move, which gets rounded too late
to 0.0

Closes #3346
---
 addons/purchase/purchase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 60fbac8a8619..be0590059aa7 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -756,7 +756,7 @@ class purchase_order(osv.osv):
             res.append(tmp)
         #if the order line has a bigger quantity than the procurement it was for (manually changed or minimal quantity), then
         #split the future stock move in two because the route followed may be different.
-        if diff_quantity > 0:
+        if float_compare(diff_quantity, 0.0, precision_rounding=order_line.product_uom.rounding) > 0:
             move_template['product_uom_qty'] = diff_quantity
             move_template['product_uos_qty'] = diff_quantity
             res.append(move_template)
-- 
GitLab