← Back to team overview

openerp-india team mailing list archive

[Bug 882036] Re: Incorrect float rounding when setting float field with too high precision

 

This issue is not completely fixed. The float_round method you added in the server must be used in the addons.
Here is a example of patch to fix a.o. the taxes computation in the addons:

=== modified file 'account/account.py'
--- account/account.py  2012-03-22 12:24:19 +0000
+++ account/account.py  2012-07-17 11:17:12 +0000
@@ -29,6 +29,7 @@
 from osv import fields, osv
 import decimal_precision as dp
 from tools.translate import _
+from tools import float_round as round
 
 def check_cycle(self, cr, uid, ids, context=None):
     """ climbs the ``self._table.parent_id`` chains for 100 levels or

=== modified file 'account/account_bank_statement.py'
--- account/account_bank_statement.py   2012-03-22 11:39:59 +0000
+++ account/account_bank_statement.py   2012-07-17 11:23:22 +0000
@@ -24,6 +24,7 @@
 from osv import fields, osv
 from tools.translate import _
 import decimal_precision as dp
+from tools import float_round as round
 
 class account_bank_statement(osv.osv):
 


** Also affects: openobject-addons
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/882036

Title:
  Incorrect float rounding when setting float field with too high
  precision

Status in OpenERP Addons (modules):
  New
Status in OpenERP GTK Client:
  Confirmed
Status in OpenERP Server:
  Fix Released
Status in OpenERP Server 6.0 series:
  Confirmed

Bug description:
  Concerns 6.0 and trunk.
  If you define a precision of 0.01, the rounding of 0.125 must be 0.13 and not 0.12. The error is in the call of the format string "%.2f"%val which introduces a mathematical error. The round function must be called to apply the correct rounding before formatting the string. It should be:
  "%.2f"%round(val*100)/100
  Fix class digits_change of class float in the server. BUT fix also the gtk client AND web client as they all have that error (I let you find the right line)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/882036/+subscriptions


References