From c3a32fc98c0a0c485798c76f0496b192ba8afa54 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 20 Sep 2017 13:21:23 +0200 Subject: [PATCH] [FIX] web: keep settings form view in edit mode when coming back using the breadcrumbs. The settings form view should always be displayed in 'edit' mode. Before this rev., it was re-rendered in 'readonly' when the user clicked on a link in a setting view (opening another view stacked in the breadcrumbs), and then came back to the settings view using the breadcrumbs. For instance, go to 'General Settings', click on 'Activity Types', come back. --- addons/web/static/src/js/chrome/view_manager.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index c76c7aecc4a..4548721690d 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -292,12 +292,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, { }).fail(view.loaded.reject.bind(view.loaded)); } else { view.loaded = view.loaded.then(function() { - // By default, the view will be loaded in readonly mode - // Returns to this default mode if you load action from breadcrumb view_options = _.extend({}, view_options, self.env); - if (view_type === 'form') { - view_options.mode = view_options.mode || 'readonly'; - } return view.controller.reload(view_options); }); } @@ -382,8 +377,14 @@ var ViewManager = Widget.extend(ControlPanelMixin, { }); }, select_view: function (index) { - var view_type = this.view_stack[index].type; - return this.switch_mode(view_type); + var viewType = this.view_stack[index].type; + var viewOptions = {}; + if (viewType === 'form') { + // reload form views in readonly, except for inline actions (i.e. + // settings views) that stay in edit + viewOptions.mode = this.action.target === 'inline' ? 'edit' : 'readonly'; + } + return this.switch_mode(viewType, viewOptions); }, /** * Renders the switch buttons for multi- and mono-record views and adds