diff --git a/product/ERP5Form/tests/testFields.py b/product/ERP5Form/tests/testFields.py index 155d1142b6125e077866a09dda2118e1077ccca6..772a245b2d59d9c5707e05f5b526d9160c6dd44e 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 e0d367e879dcd01c119258df0db393ebbae6cf9c..d00657a031f15083e0efbfa586fec095398e766f 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