summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/field_utils_tests.js
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/tests/fields/field_utils_tests.js
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/tests/fields/field_utils_tests.js')
-rw-r--r--addons/web/static/tests/fields/field_utils_tests.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/field_utils_tests.js b/addons/web/static/tests/fields/field_utils_tests.js
index bfd60000035..e00d45ef91f 100644
--- a/addons/web/static/tests/fields/field_utils_tests.js
+++ b/addons/web/static/tests/fields/field_utils_tests.js
@@ -101,7 +101,7 @@ QUnit.test('format one2many', function(assert) {
});
QUnit.test('parse float', function(assert) {
- assert.expect(6);
+ assert.expect(7);
assert.strictEqual(fieldUtils.parse.float(""), 0);
assert.strictEqual(fieldUtils.parse.float("0"), 0);
@@ -109,6 +109,16 @@ QUnit.test('parse float', function(assert) {
assert.strictEqual(fieldUtils.parse.float("-100.00"), -100);
assert.strictEqual(fieldUtils.parse.float("1,000.00"), 1000);
assert.strictEqual(fieldUtils.parse.float("1,000,000.00"), 1000000);
+
+ var originalParameters = $.extend(true, {}, core._t.database.parameters);
+ _.extend(core._t.database.parameters, {
+ grouping: [3, 0],
+ decimal_point: ',',
+ thousands_sep: '.'
+ });
+ assert.strictEqual(fieldUtils.parse.float('1.234,567'), 1234.567);
+
+ core._t.database.parameters = originalParameters;
});
QUnit.test('parse monetary', function(assert) {