# HG changeset patch
# User Houzefa Abbasbhay <houzefa.abba@xcg-consulting.fr>
# Date 1640857203 -3600
#      Thu Dec 30 10:40:03 2021 +0100
# Node ID d900f10215934baea7e2bebfa647086a6c763e58
# Parent  09606471624153b667775d5601c13dc9051281d2
import_jsonrpc: More lenient float parsing

handle commas / dots / nbspaces.

diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -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
 ------
 
diff --git a/odoo_scripts/import_jsonrpc.py b/odoo_scripts/import_jsonrpc.py
--- a/odoo_scripts/import_jsonrpc.py
+++ b/odoo_scripts/import_jsonrpc.py
@@ -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: