From 580a422487f39b2ffefecede67e8156697d532d5 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine <arnaud.fontaine@nexedi.com> Date: Fri, 19 Apr 2013 16:58:20 +0900 Subject: [PATCH] Formulator: FloatField with precision equals to 0 didn't apply input_style (ce667c1). --- product/ERP5Form/tests/testFields.py | 7 ++++++- product/Formulator/Widget.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/product/ERP5Form/tests/testFields.py b/product/ERP5Form/tests/testFields.py index 83a71ffe2d..56ac049ff4 100644 --- a/product/ERP5Form/tests/testFields.py +++ b/product/ERP5Form/tests/testFields.py @@ -87,7 +87,7 @@ class TestFloatField(ERP5TypeTestCase): def test_format_thousand_separator_point(self): self.field.values['input_style'] = '-1 234.5' self.assertEquals('1 000.0', self.widget.format_value(self.field, 1000)) - + def test_format_thousand_separator_coma(self): self.field.values['input_style'] = '-1 234,5' self.assertEquals('1 000,0', self.widget.format_value(self.field, 1000)) @@ -106,6 +106,11 @@ class TestFloatField(ERP5TypeTestCase): self.assertEquals('100,000.0', self.widget.format_value(self.field, 100000)) self.assertEquals('-100,000.0', self.widget.format_value(self.field, -100000)) + def test_format_with_separator_and_precision0(self): + self.field.values['input_style'] = '-1,234.5' + self.field.values['precision'] = 0 + self.assertEquals('-1,000', self.widget.format_value(self.field, -1000.25)) + def test_format_percent_style(self): self.field.values['input_style'] = '-12.3%' self.assertEquals('10.0%', self.widget.format_value(self.field, 0.1)) diff --git a/product/Formulator/Widget.py b/product/Formulator/Widget.py index e0d367e879..d00657a031 100644 --- a/product/Formulator/Widget.py +++ b/product/Formulator/Widget.py @@ -1823,7 +1823,8 @@ class FloatWidget(TextWidget): # just return it as is if 'e' in value: return value - value, fpart = value.split('.') + if precision != 0: + value, fpart = value.split('.') except ValueError: return value -- 2.30.9