From 6dd7efed589d79b63b1dbaddda1d4fd7eb1e74be Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Tue, 14 Sep 2021 12:16:01 +0000 Subject: [PATCH] [IMP] web: Only display search panel with sections Before this commit, the search model would consider displaying a search panel regardless of whether it had any sections. Now, the search panel is considered non-displayable when there is no sections. X-original-commit: d3b191600b50fb052a956d1199730453789674e2 Part-of: odoo/odoo#77463 --- addons/web/static/src/search/search_model.js | 1 + .../static/tests/search/search_panel_tests.js | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/search/search_model.js b/addons/web/static/src/search/search_model.js index 9576b143ab2..d367210c042 100644 --- a/addons/web/static/src/search/search_model.js +++ b/addons/web/static/src/search/search_model.js @@ -1384,6 +1384,7 @@ export class SearchModel extends EventBus { return { controlPanel: "controlPanel" in display ? display.controlPanel : {}, searchPanel: + this.sections.size && (!this.view.type || viewTypes.includes(this.view.type)) && ("searchPanel" in display ? display.searchPanel : true), }; diff --git a/addons/web/static/tests/search/search_panel_tests.js b/addons/web/static/tests/search/search_panel_tests.js index 77b594b590e..8f4b42a25c7 100644 --- a/addons/web/static/tests/search/search_panel_tests.js +++ b/addons/web/static/tests/search/search_panel_tests.js @@ -101,7 +101,7 @@ const makeTestComponent = ({ onWillStart, onWillUpdateProps } = {}) => { TestComponent.components = { FilterMenu, GroupByMenu, SearchPanel }; TestComponent.template = xml`
- +
`; @@ -282,7 +282,29 @@ QUnit.module("Search", (hooks) => { searchViewId: false, display: { searchPanel: false }, }); - assert.doesNotHaveClass(comp.el, "o_component_with_search_panel"); + assert.containsNone(comp, ".o_search_panel"); + assert.deepEqual(getDomain(), []); // initial domain + }); + + QUnit.test("basic rendering of a component with empty search panel", async (assert) => { + assert.expect(2); + + serverData.views["partner,false,search"] = ``; + + const { TestComponent, getDomain } = makeTestComponent(); + const comp = await makeWithSearch({ + serverData, + async mockRPC(route, { method, model }) { + if (/search_panel_/.test(method || route)) { + assert.step(`${method || route} on ${model}`); + } + }, + Component: TestComponent, + resModel: "partner", + searchViewId: false, + }); + + assert.containsNone(comp, ".o_search_panel"); assert.deepEqual(getDomain(), []); // initial domain }); @@ -299,7 +321,6 @@ QUnit.module("Search", (hooks) => { Component: TestComponent, resModel: "partner", searchViewId: false, - view: { type: "kanban" }, }); assert.containsOnce(comp, ".o_search_panel");