[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.
This commit is contained in:
Aaron Bohy
2018-02-20 09:39:44 +01:00
parent e7c142f6b4
commit d3372e4f8e
2 changed files with 1 additions and 4 deletions
@@ -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,
@@ -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,