From 36e03d1b9826523c0ee73cb22cf90a73ef90f41a Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Mon, 17 May 2021 16:29:56 +0200 Subject: [PATCH] [FIX] web: take into account the view flags Co-authored-by: "Lucas Perais (lpe)" --- addons/web/static/src/legacy/legacy_views.js | 4 +-- .../src/webclient/actions/action_service.js | 2 ++ .../webclient/actions/window_action_tests.js | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/legacy/legacy_views.js b/addons/web/static/src/legacy/legacy_views.js index 06e780345f0..7eb2767910d 100644 --- a/addons/web/static/src/legacy/legacy_views.js +++ b/addons/web/static/src/legacy/legacy_views.js @@ -29,7 +29,7 @@ function registerView(name, LegacyView) { this.Widget = Widget; // fool the ComponentAdapter with a simple Widget this.View = LegacyView; this.viewInfo = {}; - this.viewParams = { + this.viewParams = Object.assign({}, this.props.actionFlags, { action: this.props.action, // legacy views automatically add the last part of the breadcrumbs breadcrumbs: breadcrumbsToLegacy(this.props.breadcrumbs), @@ -48,7 +48,7 @@ function registerView(name, LegacyView) { this.props.searchPanel || (this.props.state && this.props.state.searchPanel), }, - }; + }); // Only add mode to viewParams if it is specified to avoid overwriting the default mode in some view (eg graph) if (this.props.mode) { this.viewParams.mode = this.props.mode; diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index d96330ec418..3b47d50d24b 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -352,7 +352,9 @@ function makeActionManager(env) { multiRecord: v.multiRecord, }; }); + const flags = action.flags || {}; const props = Object.assign({}, _getActionProps(action), { + actionFlags: Object.assign({}, flags, flags[view.type]), context: action.context, domain: action.domain || [], model: 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 93c01a50be6..12d2af5e6b2 100644 --- a/addons/web/static/tests/webclient/actions/window_action_tests.js +++ b/addons/web/static/tests/webclient/actions/window_action_tests.js @@ -1408,6 +1408,39 @@ QUnit.module("ActionManager", (hooks) => { ]); }); + QUnit.test("flags field of ir.actions.act_window is used", async function (assert) { + // more info about flags field : https://github.com/odoo/odoo/commit/c9b133813b250e89f1f61816b0eabfb9bee2009d + assert.expect(7); + testConfig.serverData.actions[44] = { + id: 33, + name: "Partners", + res_model: "partner", + type: "ir.actions.act_window", + flags: { + withControlPanel: false, + }, + views: [[false, "form"]], + }; + const mockRPC = async (route, args) => { + assert.step((args && args.method) || route); + }; + const webClient = await createWebClient({ testConfig, mockRPC }); + await doAction(webClient, 44); + assert.containsOnce(webClient, ".o_form_view", "should display the form view"); + assert.containsNone( + document.body, + ".o_control_panel", + "should not display the control panel" + ); + + assert.verifySteps([ + "/web/webclient/load_menus", + "/web/action/load", + "load_views", + "onchange", + ]); + }); + QUnit.test("save current search", async function (assert) { assert.expect(4); testUtils.mock.patch(ListController, {