[Erp5-report] r34755 jerome - /erp5/trunk/products/Formulator/Widget.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Apr 23 16:27:17 CEST 2010
Author: jerome
Date: Fri Apr 23 16:27:16 2010
New Revision: 34755
URL: http://svn.erp5.org?rev=34755&view=rev
Log:
if precision is defined on the field, use this precision to format; only use
repr if no precision is defined. If number is so big that it can only be
displayed in scientific notation, return it as is.
Modified:
erp5/trunk/products/Formulator/Widget.py
Modified: erp5/trunk/products/Formulator/Widget.py
URL: http://svn.erp5.org/erp5/trunk/products/Formulator/Widget.py?rev=34755&r1=34754&r2=34755&view=diff
==============================================================================
--- erp5/trunk/products/Formulator/Widget.py [utf8] (original)
+++ erp5/trunk/products/Formulator/Widget.py [utf8] Fri Apr 23 16:27:16 2010
@@ -1649,10 +1649,16 @@
try :
float_value = float(value)
if precision not in (None, ''):
- float_value = round(float_value, precision)
- # we use repr that have a better precision than str
- value = repr(float_value)
+ # if we have a precision, then use it now
+ value = ('%%0.%sf' % precision) % float_value
+ else:
+ # if no precision, we use repr which have a better precision than str
+ value = repr(float_value)
except ValueError:
+ return value
+ # if this number displayed in scientific notification, just return it as
+ # is
+ if 'e' in value:
return value
value_list = value.split('.')
integer = value_list[0]
More information about the Erp5-report
mailing list