diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index d8f0e3776d9..c3835686e11 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -286,7 +286,9 @@ var ViewManager = Widget.extend(ControlPanelMixin, { }).fail(view.loaded.reject.bind(view.loaded)); } else { view.loaded = view.loaded.then(function() { - view_options = _.extend({}, view_options, self.env); + // By default, the view will be loaded in readonly mode + // Returns to this default mode if you load action from breadcrumb + view_options = _.extend({mode: 'readonly'}, view_options, self.env); return view.controller.reload(view_options); }); } diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index 9bb1aaaaacf..d73c5cb0ef1 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -452,7 +452,8 @@ var FormController = BasicController.extend({ } else if (attrs.special) { def = this._callButtonAction(attrs, event.data.record); } else { - def = this.saveRecord().then(function () { + // save the record but don't switch to readonly mode + def = this.saveRecord({stayInEdit: true}).then(function () { return self._callButtonAction(attrs, event.data.record); }); } diff --git a/addons/web/static/test/views/form_tests.js b/addons/web/static/test/views/form_tests.js index 4bc4e73a5a6..83f337e7799 100644 --- a/addons/web/static/test/views/form_tests.js +++ b/addons/web/static/test/views/form_tests.js @@ -1113,14 +1113,13 @@ QUnit.module('Views', { }); form.$('.oe_stat_button').first().click(); assert.strictEqual(count, 1, "should have triggered a execute action"); - assert.strictEqual(form.mode, "readonly", "form view should be in readonly mode"); + assert.strictEqual(form.mode, "edit", "form view should be in edit mode"); - form.$buttons.find('.o_form_button_edit').click(); form.$('input').val("tralala").trigger('input'); form.$('.oe_stat_button').first().click(); - assert.strictEqual(form.mode, "readonly", "form view should be in readonly mode"); + assert.strictEqual(form.mode, "edit", "form view should be in edit mode"); assert.strictEqual(count, 2, "should have triggered a execute action"); form.destroy(); });