From 6adcd292b36c40f75d4dd197c68cd48ebd0b95c1 Mon Sep 17 00:00:00 2001 From: Mathieu Duckerts-Antoine Date: Mon, 19 Jun 2023 08:30:36 +0000 Subject: [PATCH] [FIX] web: search panel: fields should not be added in search bar Let us consider the search arch The two tags "field" are supposed to generate different objects: - the first one should generate an entry in the search bar autocompletion - the second one should generate a search panel section. It turns out that the second field did also generate an entry in the search bar. This is of course wrong. We fix that problem and add a test. closes odoo/odoo#125724 X-original-commit: 7e62e3cf569e59a676a834198854f415fa0ae590 Signed-off-by: Julien Mougenot (jum) Signed-off-by: Mathieu Duckerts-Antoine --- .../static/src/search/search_arch_parser.js | 3 +-- .../static/tests/search/search_model_tests.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/search/search_arch_parser.js b/addons/web/static/src/search/search_arch_parser.js index fbb270d982a..61911f02a0d 100644 --- a/addons/web/static/src/search/search_arch_parser.js +++ b/addons/web/static/src/search/search_arch_parser.js @@ -69,8 +69,7 @@ export class SearchArchParser extends XMLParser { this.visitSearch(node, visitChildren); break; case "searchpanel": - this.visitSearchPanel(node); - break; + return this.visitSearchPanel(node); case "group": this.visitGroup(node, visitChildren); break; diff --git a/addons/web/static/tests/search/search_model_tests.js b/addons/web/static/tests/search/search_model_tests.js index 10fd547c0fa..0e8d14c0e2f 100644 --- a/addons/web/static/tests/search/search_model_tests.js +++ b/addons/web/static/tests/search/search_model_tests.js @@ -965,6 +965,25 @@ QUnit.module("Search", (hooks) => { assert.deepEqual(model.domain, [["date_deadline", "<", "2021-09-17"]]); }); + QUnit.test("no search items created for search panel sections", async function (assert) { + const model = await makeSearchModel({ + serverData, + searchViewArch: ` + + + + + + + `, + resModel: "partner", + config: { viewType: "kanban" }, + }); + const sections = model.getSections(); + assert.strictEqual(sections.length, 2); + assert.deepEqual(sanitizeSearchItems(model), []); + }); + QUnit.test( "a field of type 'properties' should not be accepted as a search_default", async function (assert) {