summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2017-05-24 16:14:32 +0200
committerAaron Bohy <aab@odoo.com>2017-05-30 13:04:06 +0200
commita0c16e9cd2fc37dc5962daa0311c85add76535b3 (patch)
tree29de1ecaef7583a18248fb48469a046db97f6ab8 /addons/web/static/src
parent2742722d3634170ed060cbf5e8371bfaeb86c0e0 (diff)
[ADD] web: special = save on form buttons
Add support for value 'save' to attribute 'special' for buttons in form view. This is useful for form views in dialogs. When clicked, it saves the form view and closes the dialog (the default 'Save' button doesn't close the dialog). Without this, the only way to achieve that was to define a dummy python method and call it with <button type="object" name="dummy_method"/>.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome/view_manager.js4
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js4
2 files changed, 4 insertions, 4 deletions
diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js
index aa0b383fd92..bc441f7accf 100644
--- a/addons/web/static/src/js/chrome/view_manager.js
+++ b/addons/web/static/src/js/chrome/view_manager.js
@@ -547,7 +547,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
*
* @param {Object} action_data the action descriptor data
* @param {String} action_data.name the action name, used to uniquely identify the action to find and execute it
- * @param {String} [action_data.special=null] special action handlers (currently: only ``'cancel'``)
+ * @param {String} [action_data.special=null] special action handlers, closes the dialog if set
* @param {String} [action_data.type='workflow'] the action type, if present, one of ``'object'``, ``'action'`` or ``'workflow'``
* @param {Object} [action_data.context=null] additional action context, to add to the current context
* @param {DataSet} dataset a dataset object used to communicate with the server
@@ -589,7 +589,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
}
};
- if (action_data.special === 'cancel') {
+ if (action_data.special) {
return handler({"type":"ir.actions.act_window_close"});
} else if (action_data.type === "object") {
var args = record_id ? [[record_id]] : [this.env.ids];
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 99d21552be6..4239edbb199 100644
--- a/addons/web/static/src/js/views/form/form_controller.js
+++ b/addons/web/static/src/js/views/form/form_controller.js
@@ -334,9 +334,9 @@ var FormController = BasicController.extend({
d.resolve();
});
def = d.promise();
- } else if (attrs.special) {
+ } else if (attrs.special === 'cancel') {
def = this._callButtonAction(attrs, event.data.record);
- } else {
+ } else if (!attrs.special || attrs.special === 'save') {
// save the record but don't switch to readonly mode
def = this.saveRecord(this.handle, {
stayInEdit: true,