From 36d07bfc0f5b9841b17f4cfdf2ffb029ea1280e0 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Mon, 5 Feb 2018 16:56:54 +0100 Subject: [PATCH] [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 --- .../src/js/views/basic/basic_controller.js | 2 +- addons/web/static/tests/views/list_tests.js | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 5fc68e3124e..c7345a22ccc 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -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); diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 33b44948fca..b03e3ff534d 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -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: '', + }); + + 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);