From 66dd126053887a9c98724593012f25c8a5dd8a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 27 Jul 2018 17:00:32 +0200 Subject: [FIX] web: empty input for empty password field Revision on https://github.com/odoo/odoo/commit/4b3588feb2b7e260bf237b0f3944c90cdc47c3b5 In order to not replace characters with '*' in edit mode (because of `input` with type 'password'), the above commit did not format the value at all. The formatter of a char with the option 'isPassword' turns all of its characters into '*'. That is not intended for password inputs, because the content is hidden by the browser with the 'password' type. The issue with not using the formatter is that an empty field has the value `false`, so an empty password field produces an non-empty password input with its value to 'false'. This commit fixes the issue by forcing empty string for empty password values. Note: if you use an integer field with password, falsy values (e.g. `0`) become empty strings in the input value. --- .../web/static/tests/fields/basic_fields_tests.js | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 9ed633ad4c2..3b2fdd8686c 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1211,6 +1211,34 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('input field: empty password', function (assert) { + assert.expect(3); + + this.data.partner.records[0].foo = false; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '', + res_id: 1, + }); + + assert.strictEqual(form.$('.o_field_char').text(), "", + "password field value should be empty in read mode"); + + form.$buttons.find('.o_form_button_edit').click(); + + assert.strictEqual(form.$('input.o_field_char').attr('type'), 'password', + "password field input should be with type 'password' in edit mode"); + assert.strictEqual(form.$('input.o_field_char').val(), '', + "password field input value should be the (non-hidden, empty) password value"); + + form.destroy(); + }); + QUnit.module('UrlWidget'); QUnit.test('url widget in form view', function (assert) { -- cgit v1.2.3