diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-03-01 14:59:59 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | c5cf445462f43222a1982b613bd532018d6cad8e (patch) | |
| tree | d6cd0bc5c2ec5f2c8882768f326cb8ffd2b47794 /addons/web/static/src/js | |
| parent | 3ff7ff3e94e4fe34ec09a45fda04f0c8de33cd32 (diff) | |
[FIX] web: Form: protect against widget destruction
When a button is clicked in a form view, the event 'execute_action'
is triggered up and catched by the view_manager, which can do
various async stuff. Meanwhile, the form view might be destroyed,
and in this case, the handlers shouldn't be executed when the
async stuff is done.
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/form/form_controller.js | 11 |
1 files changed, 8 insertions, 3 deletions
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 498fb29453b..ceefd59d3c8 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -266,6 +266,11 @@ var FormController = BasicController.extend({ _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', { @@ -276,13 +281,13 @@ var FormController = BasicController.extend({ record_id: recordID, on_closed: function (reason) { if (!_.isObject(reason)) { - return self.reload(); + reload(); } }, - on_fail: this.reload.bind(this), + on_fail: reload, on_success: def.resolve.bind(def), }); - return def; + return this.alive(def); }, /** * @override method from FieldManagerMixin |
