[Erp5-report] r10097 - /erp5/trunk/products/ERP5/Document/Resource.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Sep 18 14:46:37 CEST 2006


Author: jp
Date: Mon Sep 18 14:46:36 2006
New Revision: 10097

URL: http://svn.erp5.org?rev=10097&view=rev
Log:
Log based calculation of precision

Modified:
    erp5/trunk/products/ERP5/Document/Resource.py

Modified: erp5/trunk/products/ERP5/Document/Resource.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Resource.py?rev=10097&r1=10096&r2=10097&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Resource.py (original)
+++ erp5/trunk/products/ERP5/Document/Resource.py Mon Sep 18 14:46:36 2006
@@ -27,8 +27,9 @@
 #
 ##############################################################################
 
+from math import log
+
 from AccessControl import ClassSecurityInfo
-
 from DateTime import DateTime
 
 from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
@@ -708,8 +709,11 @@
     def getQuantityPrecision(self):
       """Return the floating point precision of a quantity.
       """
-      quantity = str(self.getBaseUnitQuantity())
-      i = quantity.find('.')
-      if i < 0:
+      try:
+        return int(round(- log(self.getBaseUnitQuantity(), 10),0))
+      except TypeError:
         return 0
-      return len(quantity[i+1:].rstrip('0'))
+      return 0
+
+
+        




More information about the Erp5-report mailing list