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(); + }); }); });