diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-07-27 17:00:32 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-07-27 18:20:02 +0200 |
| commit | 66dd126053887a9c98724593012f25c8a5dd8a29 (patch) | |
| tree | 4e2f175b6b79d34281695abea898177233a90b88 /addons/web/static/tests/fields/basic_fields_tests.js | |
| parent | 2e440ac662fbb68fe0d9020fbe91634c3fcbc62c (diff) | |
[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.
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 28 |
1 files changed, 28 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 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: '<form>' + + '<field name="foo" password="True"/>' + + '</form>', + 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) { |
