Skip to content
Snippets Groups Projects
Commit c98c9e7c authored by Hubert Van de Walle (huvw)'s avatar Hubert Van de Walle (huvw)
Browse files

[FIX] board: Add to dashboard no longer saves default filters


When adding a view to the dashboard, we already save the domain.
We don't want to save the default filters as they can have an opposite
domain as the one selected, meaning no records will be matched when
going to the dashboard.

---

opw-3385248

closes odoo/odoo#132328

Signed-off-by: default avatarAaron Bohy (aab) <aab@odoo.com>
parent 97ffffbe
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,11 @@ export class AddToBoard extends Component {
orderBy,
} = this.env.searchModel.getPreFavoriteValues();
const contextToSave = {
...globalContext,
...Object.fromEntries(
Object.entries(globalContext).filter(
(entry) => !entry[0].startsWith("search_default_")
)
),
...context,
comparison,
orderedBy: orderBy,
......
......@@ -11,7 +11,10 @@ import {
import {
applyFilter,
applyGroup,
editConditionField,
editConditionOperator,
editConditionValue,
removeFacet,
toggleAddCustomFilter,
toggleAddCustomGroup,
toggleComparisonMenu,
......@@ -452,4 +455,68 @@ QUnit.module("Board", (hooks) => {
await testUtils.fields.editInput(input, "Pipeline");
await triggerEvent(input, null, "keydown", { key: "Enter" });
});
QUnit.test("Add a view to dashboard doesn't save default filters", async function (assert) {
assert.expect(2);
serverData.views = {
"partner,false,pivot": '<pivot><field name="foo"/></pivot>',
"partner,false,list": '<list><field name="foo"/></list>',
"partner,false,search": `
<search>
<filter name="filter" domain="[('foo','!=','yop')]"/>
</search>`,
};
registry.category("services").add("user", makeFakeUserService());
patchWithCleanup(browser, { setTimeout: (fn) => fn() }); // makes mouseEnter work
const mockRPC = (route, args) => {
if (route === "/board/add_to_dashboard") {
assert.deepEqual(args.domain, [["foo", "=", "yop"]]);
assert.deepEqual(args.context_to_save, {
pivot_measures: ["__count"],
pivot_column_groupby: [],
pivot_row_groupby: [],
orderedBy: [],
group_by: [],
dashboard_merge_domains_contexts: false,
});
return Promise.resolve(true);
}
};
const webClient = await createWebClient({ serverData, mockRPC });
await doAction(webClient, {
id: 1,
res_model: "partner",
type: "ir.actions.act_window",
views: [
[false, "list"],
[false, "pivot"],
],
context: { search_default_filter: 1 },
});
await click(target, ".o_switch_view.o_pivot");
// Remove default filter ['foo', '!=', 'yop']
await removeFacet(target);
// Add a filter ['foo', '=', 'yop']
await toggleFilterMenu(target);
await toggleAddCustomFilter(target);
await editConditionField(target, 0, "foo");
await editConditionOperator(target, 0, "=");
await editConditionValue(target, 0, "yop");
await applyFilter(target);
// Add to dashboard
await toggleFavoriteMenu(target);
await mouseEnter(target.querySelector(".o_add_to_board .dropdown-toggle"));
const input = target.querySelector(".o_add_to_board .dropdown-menu input");
await testUtils.fields.editInput(input, "Pipeline");
await triggerEvent(input, null, "keydown", { key: "Enter" });
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment