[FIX] web: remove search_default and group_by context keys when clicking on graph

closes odoo/odoo#80463

Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Philippe Wauthy
2022-01-25 09:57:10 +00:00
parent ef1e5f8c40
commit a49e569bef
2 changed files with 56 additions and 0 deletions
@@ -71,6 +71,12 @@ export class GraphView extends Component {
onGraphClicked(domain) {
const { context, resModel, title } = this.model.metaData;
Object.keys(context).forEach((x) => {
if (x === "group_by" || x.startsWith("search_default_")) {
delete context[x];
}
});
const views = {};
for (const [viewId, viewType] of this.env.config.views || []) {
views[viewType] = viewId;
@@ -2805,6 +2805,56 @@ QUnit.module("Views", (hooks) => {
await clickOnDataset(graph);
});
QUnit.test("Clicking on bar charts removes group_by and search_default_* context keys", async function(assert) {
assert.expect(2);
serviceRegistry.add(
"action",
{
start() {
return {
doAction(actionRequest, options) {
assert.deepEqual(actionRequest, {
context: {
lang: "en",
tz: "taht",
uid: 7,
},
domain: [["bar", "=", true]],
name: "Foo Analysis",
res_model: "foo",
target: "current",
type: "ir.actions.act_window",
views: [
[false, "list"],
[false, "form"],
],
});
assert.deepEqual(options, { viewType: "list" });
},
};
},
},
{ force: true }
);
const graph = await makeView({
serverData,
type: "graph",
resModel: "foo",
arch: `
<graph string="Foo Analysis">
<field name="bar"/>
</graph>
`,
context: {
search_default_user: 1,
group_by: 'bar',
},
});
await clickOnDataset(graph);
});
QUnit.test(
"clicking on a pie chart trigger a do_action with correct views",
async function (assert) {