From ace9f6c2da72b03fcba6f6fd1d6d105dce0693f7 Mon Sep 17 00:00:00 2001 From: Mathieu Duckerts-Antoine Date: Tue, 23 Nov 2021 14:34:51 +0000 Subject: [PATCH] [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) --- .../src/webclient/actions/action_service.js | 6 +++++- .../webclient/actions/window_action_tests.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index a48fe3d3721..32d3749fb2c 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -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, diff --git a/addons/web/static/tests/webclient/actions/window_action_tests.js b/addons/web/static/tests/webclient/actions/window_action_tests.js index e367bcf152c..727b7abe3af 100644 --- a/addons/web/static/tests/webclient/actions/window_action_tests.js +++ b/addons/web/static/tests/webclient/actions/window_action_tests.js @@ -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"] = ``; + 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); + }); });