summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_controller.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-04-23 13:51:52 +0200
committerGéry Debongnie <ged@odoo.com>2017-04-24 10:43:20 +0200
commita765ff503d3d60eb1dbc3a2c175b60fcafdcd083 (patch)
treed668ea14468d685b7f693250a212b5590615525d /addons/web/static/src/js/views/basic/basic_controller.js
parente59c1b49c2d9729e5f7576e1c205701a340f9396 (diff)
[FIX] web: reload list view after button action
Before this commit, the code that handled buttons in list view was kind of simple, and did not reload the view after. But clicking on action button is not only a problem for the list view, the form view already had something in the controller doing exactly that. With this commit, we move that code to the basic controller, and use the method in the list view.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js
index 5293ee6f4b6..7beb15a9d70 100644
--- a/addons/web/static/src/js/views/basic/basic_controller.js
+++ b/addons/web/static/src/js/views/basic/basic_controller.js
@@ -88,6 +88,41 @@ return AbstractController.extend(FieldManagerMixin, {
//--------------------------------------------------------------------------
/**
+ * When the user clicks on a 'action button', this function determines what
+ * should happen.
+ *
+ * @private
+ * @param {Object} attrs the attrs of the button clicked
+ * @param {Object} [record] the current state of the view
+ * @returns {Deferred}
+ */
+ _callButtonAction: function (attrs, record) {
+ var self = this;
+ var def = $.Deferred();
+ var reload = function () {
+ if (!self.isDestroyed()) {
+ self.reload();
+ }
+ };
+ record = record || this.model.get(this.handle);
+ var recordID = record.data.id;
+ this.trigger_up('execute_action', {
+ action_data: _.extend({}, attrs, {
+ context: record.getContext({additionalContext: attrs.context}),
+ }),
+ model: record.model,
+ record_id: recordID,
+ on_closed: function (reason) {
+ if (!_.isObject(reason)) {
+ reload();
+ }
+ },
+ on_fail: reload,
+ on_success: def.resolve.bind(def),
+ });
+ return this.alive(def);
+ },
+ /**
* Called by the field manager mixin to confirm that a change just occured
* (after that potential onchanges have been applied).
*