summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-05-04 14:57:30 +0200
committerAaron Bohy <aab@odoo.com>2017-05-04 15:48:44 +0200
commit32d669da1febb331986c8a6fb541f0356387676a (patch)
tree4a0bbbbe8b263fde4685582beee7eba90639f850 /addons/web/static/tests
parent794345bad1b5432ca1349fcc27119402e5395235 (diff)
[FIX] web: correctly parse monetary fields
Before this rev., the function that parses monetary fields (i.e. the one that converts the string value of the input into a numerical value) totally ignored the sign of the value. Actually, parsing a monetary field is exactly the same as parsing a float field, so we simply use the same function.
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/fields/field_utils_tests.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/field_utils_tests.js b/addons/web/static/tests/fields/field_utils_tests.js
index a03d42179f6..d56f077b828 100644
--- a/addons/web/static/tests/fields/field_utils_tests.js
+++ b/addons/web/static/tests/fields/field_utils_tests.js
@@ -92,5 +92,27 @@ QUnit.test('format one2many', function(assert) {
assert.strictEqual(fieldUtils.format.one2many({data: [1]}), '1 record');
assert.strictEqual(fieldUtils.format.one2many({data: [1, 2]}), '2 records');
});
+
+QUnit.test('parse float', function(assert) {
+ assert.expect(6);
+
+ assert.strictEqual(fieldUtils.parse.float(""), 0);
+ assert.strictEqual(fieldUtils.parse.float("0"), 0);
+ assert.strictEqual(fieldUtils.parse.float("100.00"), 100);
+ 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);
+});
+
+QUnit.test('parse monetary', function(assert) {
+ assert.expect(6);
+
+ assert.strictEqual(fieldUtils.parse.monetary(""), 0);
+ assert.strictEqual(fieldUtils.parse.monetary("0"), 0);
+ assert.strictEqual(fieldUtils.parse.monetary("100.00"), 100);
+ assert.strictEqual(fieldUtils.parse.monetary("-100.00"), -100);
+ assert.strictEqual(fieldUtils.parse.monetary("1,000.00"), 1000);
+ assert.strictEqual(fieldUtils.parse.monetary("1,000,000.00"), 1000000);
+});
});
});