[FIX] web: take into account the view flags

Co-authored-by: "Lucas Perais (lpe)" <lpe@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2021-06-18 21:31:28 +02:00
committed by Aaron Bohy
co-authored by Lucas Perais (lpe)
parent ce4e6bd4b1
commit 36e03d1b98
3 changed files with 37 additions and 2 deletions
+2 -2
View File
@@ -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;
@@ -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,
@@ -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, {