diff --git a/addons/web/static/src/search/control_panel/control_panel.js b/addons/web/static/src/search/control_panel/control_panel.js
index 9db06294bdf..f4cb99b373b 100644
--- a/addons/web/static/src/search/control_panel/control_panel.js
+++ b/addons/web/static/src/search/control_panel/control_panel.js
@@ -95,10 +95,7 @@ export class ControlPanel extends Component {
}
ControlPanel.components = {
- ComparisonMenu,
- FavoriteMenu,
- FilterMenu,
- GroupByMenu,
+ ...Object.values(MAPPING),
Pager,
SearchBar,
};
diff --git a/addons/web/static/src/search/group_by_menu/group_by_menu.js b/addons/web/static/src/search/group_by_menu/group_by_menu.js
index a99b034cdf2..4c5d8223561 100644
--- a/addons/web/static/src/search/group_by_menu/group_by_menu.js
+++ b/addons/web/static/src/search/group_by_menu/group_by_menu.js
@@ -26,6 +26,13 @@ export class GroupByMenu extends Component {
useBus(this.env.searchModel, "update", this.render);
}
+ /**
+ * @returns {boolean}
+ */
+ get hideCustomGroupBy() {
+ return this.env.searchModel.hideCustomGroupBy || false;
+ }
+
/**
* @returns {Object[]}
*/
diff --git a/addons/web/static/src/search/group_by_menu/group_by_menu.xml b/addons/web/static/src/search/group_by_menu/group_by_menu.xml
index b2911a39b41..d6e90e5e0a4 100644
--- a/addons/web/static/src/search/group_by_menu/group_by_menu.xml
+++ b/addons/web/static/src/search/group_by_menu/group_by_menu.xml
@@ -43,7 +43,7 @@
-
+
diff --git a/addons/web/static/src/search/search_model.js b/addons/web/static/src/search/search_model.js
index 3396494808f..e3b17b43d0a 100644
--- a/addons/web/static/src/search/search_model.js
+++ b/addons/web/static/src/search/search_model.js
@@ -212,13 +212,14 @@ export class SearchModel extends EventBus {
// used to avoid useless recomputations
this._reset();
- const { comparison, context, domain, groupBy, orderBy } = config;
+ const { comparison, context, domain, groupBy, hideCustomGroupBy, orderBy } = config;
this.globalComparison = comparison;
this.globalContext = toRaw(context || {});
this.globalDomain = domain || [];
this.globalGroupBy = groupBy || [];
this.globalOrderBy = orderBy || [];
+ this.hideCustomGroupBy = hideCustomGroupBy;
this.searchMenuTypes = new Set(config.searchMenuTypes || ["filter", "groupBy", "favorite"]);
diff --git a/addons/web/static/src/search/with_search/with_search.js b/addons/web/static/src/search/with_search/with_search.js
index 1c7b3367d19..5eded123282 100644
--- a/addons/web/static/src/search/with_search/with_search.js
+++ b/addons/web/static/src/search/with_search/with_search.js
@@ -86,5 +86,6 @@ WithSearch.props = {
// extra options
activateFavorite: { type: Boolean, optional: true },
dynamicFilters: { type: Array, element: Object, optional: true },
+ hideCustomGroupBy: { type: Boolean, optional: true },
searchMenuTypes: { type: Array, element: String, optional: true },
};
diff --git a/addons/web/static/src/views/view.js b/addons/web/static/src/views/view.js
index e4c467a8437..dbaad5586f8 100644
--- a/addons/web/static/src/views/view.js
+++ b/addons/web/static/src/views/view.js
@@ -85,6 +85,7 @@ export function getDefaultConfig() {
*
* @property {boolean} [activateFavorite]
* @property {Object[]} [dynamicFilters]
+ * @property {boolean} [hideCustomGroupBy]
* @property {string[]} [searchMenuTypes]
* @property {Object} [globalState]
*/
@@ -123,6 +124,7 @@ const STANDARD_PROPS = [
"activateFavorite",
"dynamicFilters",
+ "hideCustomGroupBy",
"searchMenuTypes",
// LEGACY: remove this later (clean when mappings old state <-> new state are established)
@@ -321,6 +323,7 @@ export class View extends Component {
this.componentProps = finalProps;
this.withSearchProps = {
...toRaw(props),
+ hideCustomGroupBy: props.hideCustomGroupBy || descr.hideCustomGroupBy,
searchMenuTypes,
SearchModel: descr.SearchModel,
};
diff --git a/addons/web/static/tests/search/group_by_menu_tests.js b/addons/web/static/tests/search/group_by_menu_tests.js
index f9fe8f2ef61..d8eb350c2f0 100644
--- a/addons/web/static/tests/search/group_by_menu_tests.js
+++ b/addons/web/static/tests/search/group_by_menu_tests.js
@@ -457,4 +457,69 @@ QUnit.module("Search", (hooks) => {
assert.deepEqual(controlPanel.env.searchModel.groupBy, []);
assert.deepEqual(getFacetTexts(target), []);
});
+
+ QUnit.test("Custom group by menu is displayed when hideCustomGroupBy is not set", async function (assert) {
+
+ await makeWithSearch({
+ serverData,
+ resModel: "foo",
+ Component: ControlPanel,
+ searchViewId: false,
+ searchViewArch: `
+
+
+
+
+ `,
+ searchMenuTypes: ["groupBy"],
+ });
+
+ await toggleGroupByMenu(target);
+
+ assert.containsOnce(target, ".o_add_custom_group_menu");
+ });
+
+ QUnit.test("Custom group by menu is displayed when hideCustomGroupBy is false", async function (assert) {
+
+ await makeWithSearch({
+ serverData,
+ resModel: "foo",
+ Component: ControlPanel,
+ searchViewId: false,
+ searchViewArch: `
+
+
+
+
+ `,
+ hideCustomGroupBy: false,
+ searchMenuTypes: ["groupBy"],
+ });
+
+ await toggleGroupByMenu(target);
+
+ assert.containsOnce(target, ".o_add_custom_group_menu");
+ });
+
+ QUnit.test("Custom group by menu is displayed when hideCustomGroupBy is true", async function (assert) {
+
+ await makeWithSearch({
+ serverData,
+ resModel: "foo",
+ Component: ControlPanel,
+ searchViewId: false,
+ searchViewArch: `
+
+
+
+
+ `,
+ hideCustomGroupBy: true,
+ searchMenuTypes: ["groupBy"],
+ });
+
+ await toggleGroupByMenu(target);
+
+ assert.containsNone(target, ".o_add_custom_group_menu");
+ });
});