summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-05-31 15:52:58 +0200
committerGéry Debongnie <ged@odoo.com>2017-05-31 19:31:07 +0200
commit5ff7199562132ccefd69ce84ce0c2c2984a40e26 (patch)
treec21048cdf7146da7c363e9a76ade5b37126f9703 /addons/web/static/src
parenta5f139a5041acf3160b07c64d316daf9c033ac5c (diff)
[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...
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/fields/field_utils.js5
1 files changed, 4 insertions, 1 deletions
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)) {