From d3372e4f8eace7ee8dfc37900f74198318662980 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 19 Feb 2018 13:42:11 +0100 Subject: [PATCH] [FIX] web: ActionManager: don't rely on view_mode When executing an act_window action, the ActionManager has to determine whether or not the first view of the action is a form view (typically, when this happens, this is also the only view of the action, and most of the time, it is displayed in a dialog, i.e. the action's target is 'new'). This ensures that the control panel is correctly shown/hidden, that form buttons are correctly rendered and displayed at the right place, and so on. Before this rev., it uses the view_mode to do that, but there is no guarantee that the view_mode is even defined (for instance, actions returned from python methods don't have to define it), so from now on, we use the 'views' attribute instead, which must always be set. --- addons/web/static/src/js/chrome/action_manager_act_window.js | 2 +- addons/web/static/tests/chrome/action_manager_tests.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js index 7963af8ec32..9cfa99a9e7d 100644 --- a/addons/web/static/src/js/chrome/action_manager_act_window.js +++ b/addons/web/static/src/js/chrome/action_manager_act_window.js @@ -329,7 +329,7 @@ ActionManager.include({ _generateActionFlags: function (action) { var popup = action.target === 'new'; var inline = action.target === 'inline'; - var form = _.str.startsWith(action.view_mode, 'form'); + var form = action.views[0][1] === 'form'; return _.defaults({}, action.flags, { disableCustomFilters: action.context && action.context.search_disable_custom_filters, footerToButtons: popup, diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index c85e8a8c42c..90b3c1bf510 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -66,7 +66,6 @@ QUnit.module('ActionManager', { res_model: 'partner', target: 'new', type: 'ir.actions.act_window', - view_mode: 'form', views: [[false, 'form']], }, { id: 6, @@ -75,7 +74,6 @@ QUnit.module('ActionManager', { res_model: 'partner', target: 'inline', type: 'ir.actions.act_window', - view_mode: 'form', views: [[false, 'form']], }, { id: 7, @@ -135,7 +133,6 @@ QUnit.module('ActionManager', { this.actions[3].views = [[false, 'form']]; this.actions[3].target = 'inline'; - this.actions[3].view_mode = 'form'; var actionManager = createActionManager({ actions: this.actions,