From 5f35819fff8090a3040edee3bc62b5078737403f Mon Sep 17 00:00:00 2001 From: Priyanka Kakadiya Date: Wed, 10 Jul 2019 11:15:26 +0000 Subject: [PATCH] [IMP] web: remove 'ID' field from custom groupby dropdown purpose of this commit is to remove ID from the fields to group by on the searchview as it does not work nor does it make sense. removed field 'ID' from custom group by on search view. task-2028105 closes odoo/odoo#34752 Signed-off-by: Aaron Bohy (aab) --- .../control_panel/search/groupby_menu.js | 2 +- .../tests/views/search_groupby_menu_tests.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/control_panel/search/groupby_menu.js b/addons/web/static/src/js/views/control_panel/search/groupby_menu.js index a41bd1c23b5..348e2e8fced 100644 --- a/addons/web/static/src/js/views/control_panel/search/groupby_menu.js +++ b/addons/web/static/src/js/views/control_panel/search/groupby_menu.js @@ -39,7 +39,7 @@ var GroupByMenu = DropdownMenu.extend({ // determines list of options used by groupBys of type 'date' this.groupableFields = []; _.each(fields, function (field, name) { - if (field.sortable && _.contains(GROUPABLE_TYPES, field.type)) { + if (field.sortable && name !== "id" && _.contains(GROUPABLE_TYPES, field.type)) { self.groupableFields.push(_.extend({}, field, { name: name, })); diff --git a/addons/web/static/tests/views/search_groupby_menu_tests.js b/addons/web/static/tests/views/search_groupby_menu_tests.js index 662b3c8518b..6ff0e7eaf13 100644 --- a/addons/web/static/tests/views/search_groupby_menu_tests.js +++ b/addons/web/static/tests/views/search_groupby_menu_tests.js @@ -176,5 +176,25 @@ QUnit.module('GroupByMenu', { groupByMenu.destroy(); }); + + QUnit.test('custom group by dropdown should not have ID field', async function (assert) { + assert.expect(2); + + this.fields.id = {sortable: true, string: 'ID', type: 'integer'}; + + var groupByMenu = await createGroupByMenu([], this.fields); + // open groupBy menu + await testUtils.dom.click(groupByMenu.$('button:first')); + // open Add Custom Group submenu + await testUtils.dom.click(groupByMenu.$('.o_add_custom_group')) + + assert.containsOnce(groupByMenu, '.o_group_selector option', + 'groupby menu should have only one option'); + // custom group by should not have 'ID' field + assert.containsNone(groupByMenu, '.o_group_selector option[value="id"]', + 'id field should not be in custom group by'); + + groupByMenu.destroy(); + }); }); });