[FIX] web: distribute ! or not
When the domain selector is in debug mode (props.isDebugMode = true),
the operator ! (not) is not distributed in the leaves in the domain
selector. That is a domain like ["!", "|", ("foo", "=", 1 ), ("id", "=", 2)]
will be visualized in the domain selector as
Match records with none of the following rules:
Foo = 1
ID = 2
The problem we fix is that when such a domain is added via "Add Custom
Filter" (for instance), the search bar facet produced has a representation
of the domain where ! has been distributed even if the debug mode is
active. With the previous example:
------------ -----------
| Foo != 1 | | ID != 2 |
------------ -----------
This makes the user think that the domain she sees is not the domain
she has created.
In the present commit, we make sure that the ! operator is distributed
or not uniformly within the scope of the search model.
closes odoo/odoo#125967
X-original-commit: d15d7e13be0ca6f7705c3bb6f992b45949bccef0
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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: `<search />`,
|
||||
});
|
||||
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]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user