Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Odoo scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo scripts
Commits
d900f102
Commit
d900f102
authored
3 years ago
by
Houzefa Abbasbhay
Browse files
Options
Downloads
Patches
Plain Diff
import_jsonrpc: More lenient float parsing
handle commas / dots / nbspaces.
parent
09606471
No related branches found
No related tags found
1 merge request
!68
🔖 14.0.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NEWS.rst
+2
-0
2 additions, 0 deletions
NEWS.rst
odoo_scripts/import_jsonrpc.py
+11
-1
11 additions, 1 deletion
odoo_scripts/import_jsonrpc.py
with
13 additions
and
1 deletion
NEWS.rst
+
2
−
0
View file @
d900f102
...
...
@@ -13,6 +13,8 @@
``import_jsonrpc``: Add ``--allow-import-errors`` & ``--allow-missing-refs`` to log warnings without blocking errors.
``import_jsonrpc``: More lenient float parsing - handle commas / dots / nbspaces.
13.3.0
------
...
...
This diff is collapsed.
Click to expand it.
odoo_scripts/import_jsonrpc.py
+
11
−
1
View file @
d900f102
...
...
@@ -104,7 +104,17 @@
return
int
(
value
)
if
value
else
0
def
_convert_float
(
value
)
->
float
:
return
float
(
value
)
if
value
else
0.0
"""
Convert string to float, handle commas / dots / nbspaces.
From <https://stackoverflow.com/a/55004691>.
"""
if
not
value
:
return
0.0
value
=
value
.
replace
(
"
\xa0
"
,
""
)
# Remove nbspaces.
if
value
.
rfind
(
"
,
"
)
>
value
.
rfind
(
"
.
"
):
value
=
value
.
replace
(
"
.
"
,
""
).
replace
(
"
,
"
,
"
.
"
)
else
:
value
=
value
.
replace
(
"
,
"
,
""
)
return
float
(
value
)
def
_convert_many2one
(
xmlid
:
str
)
->
Union
[
None
,
int
]:
if
xmlid
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment