From b7e3469931f69091e47b4c6c2ce8a83669fa7313 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 3 Sep 2019 13:30:04 +0000 Subject: [PATCH] [FIX] web: grouped list as grouped list as child In grouped editable list, get rid of the groups Edit one record in the editable list In a M2O, click on search more In search's list, group by a field Expand a group in the search's list Before this commit, it crashes because the event was propagated onto the first main list After this commit, it doesn't crash and the group is expanded OPW 2064156 closes odoo/odoo#36383 Signed-off-by: Lucas Perais (lpe) --- .../src/js/views/list/list_controller.js | 1 + addons/web/static/tests/views/list_tests.js | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index 524bd2034db..9fb765f8ae2 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -579,6 +579,7 @@ var ListController = BasicController.extend({ * @param {OdooEvent} event */ _onToggleGroup: function (event) { + event.stopPropagation(); this.model .toggleGroup(event.data.group.id) .then(this.update.bind(this, {}, {keepSelection: true, reload: false})); diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 223aea85a93..031e691388b 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -3268,6 +3268,57 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('grouped list with another grouped list parent, click unfold', function (assert) { + assert.expect(3); + this.data.bar.fields = { + cornichon: {string: 'cornichon', type: 'char'}, + }; + + var rec = this.data.bar.records[0]; + // create records to have the search more button + var newRecs = []; + for (var i=0; i<8; i++) { + var newRec = _.extend({}, rec); + newRec.id = 10 + i; + newRec.cornichon = 'extra fin'; + newRecs.push(newRec) + } + this.data.bar.records = newRecs; + + var list = createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: '', + groupBy: ['bar'], + archs: { + 'bar,false,list': '', + 'bar,false,search': '', + }, + }); + + list.update({groupBy: []}); + + testUtilsDom.click(list.$('.o_data_cell:eq(0)')); + + testUtilsDom.click(list.$('.o_selected_row .o_data_cell .o_field_many2one input')); + $('.ui-autocomplete .ui-menu-item:contains("Search More")').mouseenter().click(); + + assert.containsOnce($('body'), '.modal-content'); + + assert.containsNone($('body'), '.modal-content .o_group_name', 'list in modal not grouped'); + + testUtilsDom.click($('body .modal-content button:contains(Group By)')); + + testUtilsDom.click($('body .modal-content .o_menu_item a:contains(cornichon)')); + + testUtilsDom.click($('body .modal-content .o_group_header')); + + assert.containsOnce($('body'), '.modal-content .o_group_open'); + + list.destroy(); + }); + QUnit.test('field values are escaped', function (assert) { assert.expect(1); var value = '';