Hardik Ansodariya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-881356-han into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
  Hardik Ansodariya (OpenERP) (han-tinyerp)
Related bugs:
  Bug #881356 in OpenERP Addons: "Floating Point / Rounding issue in stock 
partial picking wizard"
  https://bugs.launchpad.net/openobject-addons/+bug/881356

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-881356-han/+merge/87056

Hello,

I have fixed the issue of rounding precision, using tool.float_compare()

Thanks
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-881356-han/+merge/87056
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-881356-han.
=== modified file 'sale/sale.py'
--- sale/sale.py	2011-12-22 12:09:59 +0000
+++ sale/sale.py	2011-12-29 04:50:30 +0000
@@ -25,7 +25,7 @@
 import pooler
 from osv import fields, osv
 from tools.translate import _
-from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
+from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, float_compare
 import decimal_precision as dp
 import netsvc
 
@@ -1233,7 +1233,8 @@
 
         if not uom2:
             uom2 = product_obj.uom_id
-        if (product_obj.type=='product') and (product_obj.virtual_available * uom2.factor < qty * product_obj.uom_id.factor) \
+        compare_qty = float_compare(product_obj.virtual_available * uom2.factor,qty * product_obj.uom_id.factor, precision_rounding=product_obj.uom_id.rounding)
+        if (product_obj.type=='product') and int(compare_qty) == -1 \
           and (product_obj.procure_method=='make_to_stock'):
             warn_msg = _('You plan to sell %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') % \
                     (qty, uom2 and uom2.name or product_obj.uom_id.name,

=== modified file 'stock/stock.py'
--- stock/stock.py	2011-12-21 22:27:17 +0000
+++ stock/stock.py	2011-12-29 04:50:30 +0000
@@ -28,6 +28,7 @@
 from tools.translate import _
 import netsvc
 import tools
+from tools import float_compare
 import decimal_precision as dp
 import logging
 
@@ -459,7 +460,8 @@
                 continue
 
             amount = results2
-            if amount > 0:
+            compare_qty = float_compare(amount, product_qty, precision_rounding=context.get('rounding'))
+            if compare_qty <> -1:
                 if amount > min(total, product_qty):
                     amount = min(product_qty, total)
                 result.append((amount, id))
@@ -2005,7 +2007,7 @@
                 continue
             if move.state in ('confirmed', 'waiting'):
                 # Important: we must pass lock=True to _product_reserve() to avoid race conditions and double reservations
-                res = self.pool.get('stock.location')._product_reserve(cr, uid, [move.location_id.id], move.product_id.id, move.product_qty, {'uom': move.product_uom.id}, lock=True)
+                res = self.pool.get('stock.location')._product_reserve(cr, uid, [move.location_id.id], move.product_id.id, move.product_qty, {'uom': move.product_uom.id, 'rounding': move.product_uom.rounding}, lock=True)
                 if res:
                     #_product_available_test depends on the next status for correct functioning
                     #the test does not work correctly if the same product occurs multiple times

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to