summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2019-12-24 10:05:17 +0000
committerAndrea Grazioso (agr-odoo) <agr@odoo.com>2020-01-06 12:16:10 +0000
commitbbe944c8298555238708141a90bf45df3cc295ce (patch)
treed6baf6ca1d8a6173480dcd98f30f31ea342031e7 /addons/web/static/tests/fields/basic_fields_tests.js
parentf62d91670bd272870f155157686b509d3cbf8abd (diff)
[FIX] web: avoid parsing value if already number
When accessing stock_barcode module to validate pickings, is not possible to add floating point quantities for any localizaton which uses ',' as decimal separator. The numeric field is now defined via browser tags <input="numeric"> to make the numeric keyboard popup automatically on mobile devices (commit 8f5840369b28962ab2be9edfce7331a836c3df22) Adding the override to avoid further processing when the input is already anumber opw-2154657 closes odoo/odoo#42748 X-original-commit: 1ccc60deeb067f8d461d48cbf51719317c22cb90 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 99cf151baf9..2e24dd38740 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -837,6 +837,42 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('float field with type number option and comma decimal separator', async function (assert) {
+ assert.expect(4);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="qux" options="{\'type\': \'number\'}"/>' +
+ '</form>',
+ res_id: 4,
+ translateParameters: {
+ thousands_sep: ".",
+ decimal_point: ",",
+ grouping: [3, 0],
+ },
+ });
+
+ await testUtils.form.clickEdit(form);
+ assert.ok(form.$('.o_field_widget')[0].hasAttribute('type'),
+ 'Float field with option type must have a type attribute.');
+ assert.hasAttrValue(form.$('.o_field_widget'), 'type', 'number',
+ 'Float field with option type must have a type attribute equals to "number".');
+ await testUtils.fields.editInput(form.$('input[name=qux]'), '123456.789');
+ await testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
+ assert.strictEqual(form.$('.o_field_widget').val(), '123456.789',
+ 'Float value must be not formatted if input type is number.');
+ await testUtils.form.clickSave(form);
+ assert.strictEqual(form.$('.o_field_widget').text(), '123.456,8',
+ 'Float value must be formatted in readonly view even if the input type is number.');
+
+ form.destroy();
+ });
+
+
QUnit.test('float field without type number option', async function (assert) {
assert.expect(2);