summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/field_utils_tests.js
diff options
context:
space:
mode:
authorMichael Mattiello (mcm) <mcm@odoo.com>2020-01-27 07:17:49 +0000
committerMichael Mattiello (mcm) <mcm@odoo.com>2020-02-06 11:55:13 +0000
commitc5e34d77f5d84c1811e29cabdffdd408695d1d2d (patch)
treef083b7a8f74fe322be91a2bfcdbb40d8aab5ad35 /addons/web/static/tests/fields/field_utils_tests.js
parent9d85bce7db59ebf8cb65c2aa13524fdc69944eb2 (diff)
[IMP] web: show % symbol outside the input in percentage widget
Before this commit the % symbol was part of the input. We could write a value with the % symbol to divide the value by 100 (50% = 0.5, 50 = 50) This commit removes the % symbol from the input and adds it in a span after the input so we do not need to write the % symbol anymore. The value from the input will be saved as $value / 100 in database. task-2065078 closes odoo/odoo#43995 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/field_utils_tests.js')
-rw-r--r--addons/web/static/tests/fields/field_utils_tests.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/addons/web/static/tests/fields/field_utils_tests.js b/addons/web/static/tests/fields/field_utils_tests.js
index e0b9564d13c..1437b6b0506 100644
--- a/addons/web/static/tests/fields/field_utils_tests.js
+++ b/addons/web/static/tests/fields/field_utils_tests.js
@@ -135,7 +135,7 @@ QUnit.test('format binary', function (assert) {
});
QUnit.test('format percentage', function (assert) {
- assert.expect(11);
+ assert.expect(12);
var originalParameters = _.clone(core._t.database.parameters);
@@ -161,6 +161,7 @@ QUnit.test('format percentage', function (assert) {
});
assert.strictEqual(fieldUtils.format.percentage(0.125), '12,5%');
assert.strictEqual(fieldUtils.format.percentage(0.666666), '66,67%');
+ assert.strictEqual(fieldUtils.format.percentage(0.5, null, { noSymbol: true }), '50');
core._t.database.parameters = originalParameters;
});
@@ -274,17 +275,15 @@ QUnit.test('parse monetary', function(assert) {
});
QUnit.test('parse percentage', function(assert) {
- assert.expect(9);
+ assert.expect(7);
var originalParameters = _.clone(core._t.database.parameters);
assert.strictEqual(fieldUtils.parse.percentage(""), 0);
assert.strictEqual(fieldUtils.parse.percentage("0"), 0);
- assert.strictEqual(fieldUtils.parse.percentage("0%"), 0);
- assert.strictEqual(fieldUtils.parse.percentage("0.02"), 0.02);
- assert.strictEqual(fieldUtils.parse.percentage("1"), 1);
- assert.strictEqual(fieldUtils.parse.percentage("2%"), 0.02);
- assert.strictEqual(fieldUtils.parse.percentage("100%"), 1);
+ assert.strictEqual(fieldUtils.parse.percentage("0.5"), 0.005);
+ assert.strictEqual(fieldUtils.parse.percentage("1"), 0.01);
+ assert.strictEqual(fieldUtils.parse.percentage("100"), 1);
_.extend(core._t.database.parameters, {
grouping: [3, 0],
@@ -292,8 +291,8 @@ QUnit.test('parse percentage', function(assert) {
thousands_sep: '.'
});
- assert.strictEqual(fieldUtils.parse.percentage("0,04"), 0.04);
- assert.strictEqual(fieldUtils.parse.percentage("6,02%"), 0.0602);
+ assert.strictEqual(fieldUtils.parse.percentage("1.234,56"), 12.3456);
+ assert.strictEqual(fieldUtils.parse.percentage("6,02"), 0.0602);
core._t.database.parameters = originalParameters;