[FIX] web: properly handles ESC in editable lists
This is a small correction of odoo/odoo@3aad756 ; a traceback occured when ESC was pressed in a list view with modifiers. The `confirmChange` was done on the parent datapoint (of type list) which has no attribute `evalModifiers`. `confirmChange` is now called on the record datapoint. Note that for x2m, it means that all modifiers linked to the parent record won't be re-evaluated (but this wasn't probably intended as this is a bit overkill). Closes #22718
This commit is contained in:
@@ -511,7 +511,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
|
||||
// TODO this will tell the renderer to rerender the widget that
|
||||
// asked for the discard but will unfortunately lose the click
|
||||
// made on another row if any
|
||||
self._confirmChange(self.handle, [ev.data.fieldName], ev)
|
||||
self._confirmChange(recordID, [ev.data.fieldName], ev)
|
||||
.always(ev.data.onSuccess);
|
||||
})
|
||||
.fail(ev.data.onFailure);
|
||||
|
||||
@@ -2772,6 +2772,28 @@ QUnit.module('Views', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('pressing ESC discard the current line changes (with required)', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var list = createView({
|
||||
View: ListView,
|
||||
model: 'foo',
|
||||
data: this.data,
|
||||
arch: '<tree editable="top"><field name="foo" required="1"/></tree>',
|
||||
});
|
||||
|
||||
list.$buttons.find('.o_list_button_add').click();
|
||||
|
||||
list.$('input[name="foo"]').trigger({type: 'keydown', which: $.ui.keyCode.ESCAPE});
|
||||
assert.strictEqual(list.$('tr.o_data_row').length, 4,
|
||||
"should have 4 data row in list");
|
||||
assert.strictEqual(list.$('tr.o_data_row.o_selected_row').length, 0,
|
||||
"no rows should be selected");
|
||||
assert.ok(!list.$buttons.find('.o_list_button_save').is(':visible'),
|
||||
"should not have a visible save button");
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('field with password attribute', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user