Skip to content
Snippets Groups Projects
Commit d900f102 authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

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
......@@ -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
------
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment