[FIX] web: apply default favorite even if active_id(s)

Before this commit, we didn't apply the default favorite (if any),
when there was an active_id or active_ids in the context. This was
a mistake. Note that it only impacted owl views.

closes odoo/odoo#99989

X-original-commit: 1e13e6cd073e57b3744caefc4b8f3795c35a4c10
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2022-09-12 13:49:37 +02:00
parent b3489af4c1
commit 5f499d170e
2 changed files with 29 additions and 2 deletions
@@ -471,8 +471,8 @@ function makeActionManager(env) {
}
}
if (context.active_id || context.active_ids || context.search_disable_custom_filters) {
viewProps.activateFavorite = false; // not sure --> check logic
if (context.search_disable_custom_filters) {
viewProps.activateFavorite = false;
}
// view specific
@@ -1632,6 +1632,33 @@ QUnit.module("ActionManager", (hooks) => {
}
);
QUnit.test("action with default favorite and context.active_id", async function (assert) {
assert.expect(4);
serverData.actions[3].context = { active_id: 4, active_ids: [4], active_model: "whatever" };
serverData.models.partner.filters = [
{
name: "favorite filter",
id: 5,
context: "{}",
sort: "[]",
domain: '[("bar", "=", 1)]',
is_default: true,
},
];
const mockRPC = (route, args) => {
if (args.method === "web_search_read") {
assert.deepEqual(args.kwargs.domain, [["bar", "=", 1]]);
}
};
const webClient = await createWebClient({ serverData, mockRPC });
await doAction(webClient, 3);
assert.containsOnce(target, ".o_list_view");
assert.containsOnce(target, ".o_searchview .o_searchview_facet");
assert.strictEqual(target.querySelector(".o_facet_value").innerText, "favorite filter");
});
QUnit.test(
"search menus are still available when switching between actions",
async function (assert) {