From 5ff7199562132ccefd69ce84ce0c2c2984a40e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 31 May 2017 15:52:58 +0200 Subject: [FIX] web: properly parse float with '.' as thousand_sep In a slightly too naive way, we apparently tried to improve the parse_float method while rewriting the new views. This was done by using a regexp to match all occurences of a thousand separator. The way the regexp was built was fine, until the thousand separator is a '.', which, if used as a regexp, matches all characters. Also, sadly, '.' is not so rare as a thousand separator... --- addons/web/static/src/js/fields/field_utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 75403c288e5..9a6734b7baf 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -415,7 +415,10 @@ function parseDateTime(value, field, options) { } function parseFloat(value) { - value = value.replace(new RegExp(core._t.database.parameters.thousands_sep, "g"), ''); + if (core._t.database.parameters.thousands_sep) { + var escapedSep = _.str.escapeRegExp(core._t.database.parameters.thousands_sep); + value = value.replace(new RegExp(escapedSep, 'g'), ''); + } value = value.replace(core._t.database.parameters.decimal_point, '.'); var parsed = Number(value); if (isNaN(parsed)) { -- cgit v1.2.3