[FIX] web: Form: avoid to change mode on button click
When clicking on a button in a form view, the current data should be saved but the form view shouldn't be re-rendered in readonly. Before this commit, the view was re-rendered, causing a weird glitch in dialogs as buttons that were supposed to be moved to the dialog's footer appeared inside the view when the button was clicked. Also forces the default mode in form view to readonly, so that it is correctly redrawn in readonly when coming back using the breadcrumbs.
This commit is contained in:
committed by
Aaron Bohy
parent
b0fd99f261
commit
ef6b330d8f
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user