[FIX] web: properly handle autocomplete attribute
With the new views, the attribute autocomplete on input was no longer supported. We simply reintroduce its support in this commit. The basic attribute values are 'on' and 'off' but one may want to use a random string. Note that an input with type='password' is a special case: the autocomplete attribute should always be set to 'new-password' to remove autocompletion (autocomplete='off' doesn't actually remove the autocompletion).
This commit is contained in:
@@ -225,6 +225,9 @@ var InputField = DebouncedField.extend({
|
||||
this.$input.attr({
|
||||
type: this.nodeOptions.isPassword ? 'password' : 'text',
|
||||
placeholder: this.attrs.placeholder || "",
|
||||
autocomplete: this.nodeOptions.isPassword ?
|
||||
'new-password' :
|
||||
this.attrs.autocomplete,
|
||||
});
|
||||
this.$input.val(this._formatValue(this.value));
|
||||
return this.$input;
|
||||
|
||||
@@ -4709,6 +4709,30 @@ QUnit.module('Views', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('support autocomplete attribute', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<field name="display_name" autocomplete="coucou"/>' +
|
||||
'<field name="foo" password="True"/>' +
|
||||
'</form>',
|
||||
res_id: 1,
|
||||
});
|
||||
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
assert.strictEqual(form.$('input[name="foo"]').val(), '***',
|
||||
"password should be displayed with stars");
|
||||
assert.strictEqual(form.$('input[name="display_name"]').prop('autocomplete'), 'coucou',
|
||||
"attribute autocomplete should be set");
|
||||
assert.strictEqual(form.$('input[name="foo"]').prop('autocomplete'), 'new-password',
|
||||
"attribute autocomplete should be set to 'new-password' on password input");
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('context is correctly passed after save & new in FormViewDialog', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user