Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
erp5_rtl_support
Commits
580a4224
Commit
580a4224
authored
Apr 19, 2013
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formulator: FloatField with precision equals to 0 didn't apply input_style (
ce667c12
).
parent
af640e28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
product/ERP5Form/tests/testFields.py
product/ERP5Form/tests/testFields.py
+6
-1
product/Formulator/Widget.py
product/Formulator/Widget.py
+2
-1
No files found.
product/ERP5Form/tests/testFields.py
View file @
580a4224
...
@@ -87,7 +87,7 @@ class TestFloatField(ERP5TypeTestCase):
...
@@ -87,7 +87,7 @@ class TestFloatField(ERP5TypeTestCase):
def
test_format_thousand_separator_point
(
self
):
def
test_format_thousand_separator_point
(
self
):
self
.
field
.
values
[
'input_style'
]
=
'-1 234.5'
self
.
field
.
values
[
'input_style'
]
=
'-1 234.5'
self
.
assertEquals
(
'1 000.0'
,
self
.
widget
.
format_value
(
self
.
field
,
1000
))
self
.
assertEquals
(
'1 000.0'
,
self
.
widget
.
format_value
(
self
.
field
,
1000
))
def
test_format_thousand_separator_coma
(
self
):
def
test_format_thousand_separator_coma
(
self
):
self
.
field
.
values
[
'input_style'
]
=
'-1 234,5'
self
.
field
.
values
[
'input_style'
]
=
'-1 234,5'
self
.
assertEquals
(
'1 000,0'
,
self
.
widget
.
format_value
(
self
.
field
,
1000
))
self
.
assertEquals
(
'1 000,0'
,
self
.
widget
.
format_value
(
self
.
field
,
1000
))
...
@@ -106,6 +106,11 @@ class TestFloatField(ERP5TypeTestCase):
...
@@ -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
))
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
):
def
test_format_percent_style
(
self
):
self
.
field
.
values
[
'input_style'
]
=
'-12.3%'
self
.
field
.
values
[
'input_style'
]
=
'-12.3%'
self
.
assertEquals
(
'10.0%'
,
self
.
widget
.
format_value
(
self
.
field
,
0.1
))
self
.
assertEquals
(
'10.0%'
,
self
.
widget
.
format_value
(
self
.
field
,
0.1
))
...
...
product/Formulator/Widget.py
View file @
580a4224
...
@@ -1823,7 +1823,8 @@ class FloatWidget(TextWidget):
...
@@ -1823,7 +1823,8 @@ class FloatWidget(TextWidget):
# just return it as is
# just return it as is
if
'e'
in
value
:
if
'e'
in
value
:
return
value
return
value
value
,
fpart
=
value
.
split
(
'.'
)
if
precision
!=
0
:
value
,
fpart
=
value
.
split
(
'.'
)
except
ValueError
:
except
ValueError
:
return
value
return
value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment