[FIX] web: action group_by of type string
Before this commit, an action group_by like "subscription_id" was accepted in production mode but would make crash a view that uses the WithSearch component as soon as the dev mode is activated. Here we fix the problem by making the acion service process the action group_by in order to make it pass the validation. closes odoo/odoo#81306 X-original-commit: ea209f126c57ea2f3e456a9b459dd46fd78fc33a Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -399,11 +399,15 @@ function makeActionManager(env) {
|
||||
return viewSwitcherEntry;
|
||||
});
|
||||
const context = action.context || {};
|
||||
let groupBy = context.group_by || [];
|
||||
if (typeof groupBy === "string") {
|
||||
groupBy = [groupBy];
|
||||
}
|
||||
const viewProps = Object.assign({}, props, {
|
||||
context,
|
||||
display: { mode: target === "new" ? "inDialog" : target },
|
||||
domain: action.domain || [],
|
||||
groupBy: action.context.group_by || [],
|
||||
groupBy,
|
||||
loadActionMenus: target !== "new" && target !== "inline",
|
||||
loadIrFilters: action.views.some((v) => v[1] === "search"),
|
||||
resModel: action.res_model,
|
||||
|
||||
@@ -2430,4 +2430,20 @@ QUnit.module("ActionManager", (hooks) => {
|
||||
const titleService = webClient.env.services.title;
|
||||
assert.strictEqual(titleService.current, '{"zopenerp":"Odoo","action":"Partners"}');
|
||||
});
|
||||
|
||||
QUnit.test("action group_by of type string", async function (assert) {
|
||||
assert.expect(2);
|
||||
serverData.views["partner,false,pivot"] = `<pivot/>`;
|
||||
registry.category("services").add("user", makeFakeUserService());
|
||||
const webClient = await createWebClient({ serverData });
|
||||
await doAction(webClient, {
|
||||
name: "Partner",
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[3, "pivot"]],
|
||||
context: { group_by: "foo" },
|
||||
});
|
||||
assert.containsOnce(webClient, ".o_pivot_view");
|
||||
assert.containsN(webClient, ".o_pivot_view tbody th", 6);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user