diff --git a/addons/web/static/src/search/search_bar/search_bar.js b/addons/web/static/src/search/search_bar/search_bar.js index 0e4cc03372e..708743ffa99 100644 --- a/addons/web/static/src/search/search_bar/search_bar.js +++ b/addons/web/static/src/search/search_bar/search_bar.js @@ -379,7 +379,7 @@ export class SearchBar extends Component { onConfirm: (domain) => this.env.searchModel.splitAndAddDomain(domain, groupId), disableConfirmButton: (domain) => domain === `[]`, title: _t("Modify Condition"), - isDebugMode: !!this.env.debug, + isDebugMode: this.env.searchModel.isDebugMode, }); } diff --git a/addons/web/static/src/search/search_bar_menu/search_bar_menu.js b/addons/web/static/src/search/search_bar_menu/search_bar_menu.js index 79f2363e12b..020b70d87e3 100644 --- a/addons/web/static/src/search/search_bar_menu/search_bar_menu.js +++ b/addons/web/static/src/search/search_bar_menu/search_bar_menu.js @@ -75,7 +75,7 @@ export class SearchBarMenu extends Component { title: _t("Add Custom Filter"), confirmButtonText: _t("Add"), discardButtonText: _t("Cancel"), - isDebugMode: !!this.env.debug, + isDebugMode: this.env.searchModel.isDebugMode, }); } diff --git a/addons/web/static/src/search/search_model.js b/addons/web/static/src/search/search_model.js index 4e868591ed1..710f70fd835 100644 --- a/addons/web/static/src/search/search_model.js +++ b/addons/web/static/src/search/search_model.js @@ -677,6 +677,9 @@ export class SearchModel extends EventBus { return deepCopy(this._orderBy); } + get isDebugMode() { + return !!this.env.debug; + } //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- @@ -983,7 +986,7 @@ export class SearchModel extends EventBus { context = makeContext(contexts); } - const tree = toTree(domain); + const tree = toTree(domain, { distributeNot: !this.isDebugMode }); const trees = !tree.negate && tree.value === "&" ? tree.children : [tree]; const promises = trees.map(async (tree) => { const description = await this.getDomainTreeDescription(this.resModel, tree); diff --git a/addons/web/static/tests/search/search_bar_menu_tests.js b/addons/web/static/tests/search/search_bar_menu_tests.js index 048b5bd894c..1039b324fd8 100644 --- a/addons/web/static/tests/search/search_bar_menu_tests.js +++ b/addons/web/static/tests/search/search_bar_menu_tests.js @@ -1703,5 +1703,34 @@ QUnit.module("Search", (hooks) => { assert.deepEqual(getFacetTexts(target), [`ID is between 0 and 10`]); assert.deepEqual(getDomain(controlPanel), ["&", ["id", ">=", 0], ["id", "<=", 10]]); }); + + QUnit.test("consistent display of ! in debug mode", async function (assert) { + patchWithCleanup(odoo, { debug: true }); + + const controlPanel = await makeWithSearch({ + serverData, + resModel: "foo", + Component: SearchBar, + searchMenuTypes: ["filter"], + searchViewId: false, + searchViewArch: ``, + }); + await toggleSearchBarMenu(target); + await openAddCustomFilterDialog(target); + await editInput( + target, + ".o_domain_debug_input", + `["!", "|", ("foo", "=", 1 ), ("id", "=", 2)]` + ); + assert.strictEqual( + target.querySelector(".o_domain_tree_connector_caret").textContent, + "none" + ); + + await click(target.querySelector(".modal footer button")); + + assert.deepEqual(getFacetTexts(target), [`! ( Foo = 1 or ID = 2 )`]); + assert.deepEqual(getDomain(controlPanel), ["!", "|", ["foo", "=", 1], ["id", "=", 2]]); + }); }); });