From c3615c3dc600115822dc3b5a0978bd14a19ed149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Thu, 19 Jul 2007 10:19:17 +0000 Subject: [PATCH] When using precision, float fields should round the value before truncating it. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15251 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/FormulatorPatch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/product/ERP5Form/FormulatorPatch.py b/product/ERP5Form/FormulatorPatch.py index fa95794d9f..3d478388dd 100644 --- a/product/ERP5Form/FormulatorPatch.py +++ b/product/ERP5Form/FormulatorPatch.py @@ -1052,12 +1052,15 @@ class FloatWidget(TextWidget): def format_value(self, field, value): """Formats the value as requested""" if value not in (None,''): + precision = field.get_value('precision') input_style = field.get_value('input_style') percent = 0 original_value = value if input_style.find('%')>=0: percent=1 value = float(value) * 100 + if precision: + value = round(value, precision) try : value = str(float(value)) except ValueError: @@ -1077,7 +1080,6 @@ class FloatWidget(TextWidget): i += 3 else: value = value_list[0] - precision = field.get_value('precision') if precision != 0: value += '.' if precision not in (None,''): -- 2.30.9