summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-03-01 15:01:15 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit928af2b51fca5f3e120fbd7f74b77c27a104ba6a (patch)
tree662584833ce5e61ff96f5eb37bdb94a3c5b71947 /addons/web/static/src
parent979d82abe8e9458e9d31d0f0fb54c446e8abefe3 (diff)
[IMP] web: ajax service: ensure widget is alive
... before resolving/rejecting the deferred once the RPC is done. Doing this in the ajax service is equal to wrap every rpc with this.alive() in the former versions.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/core/mixins.js3
-rw-r--r--addons/web/static/src/js/services/ajax_service.js14
2 files changed, 14 insertions, 3 deletions
diff --git a/addons/web/static/src/js/core/mixins.js b/addons/web/static/src/js/core/mixins.js
index 93468e03fc0..6f640cb3300 100644
--- a/addons/web/static/src/js/core/mixins.js
+++ b/addons/web/static/src/js/core/mixins.js
@@ -456,7 +456,8 @@ var ServiceProvider = {
},
_call_service: function (event) {
var service = this.services[event.data.service];
- var result = service[event.data.method].apply(service, event.data.args);
+ var args = event.data.args.concat(event.target);
+ var result = service[event.data.method].apply(service, args);
event.data.callback(result);
},
};
diff --git a/addons/web/static/src/js/services/ajax_service.js b/addons/web/static/src/js/services/ajax_service.js
index dbcd851e203..480549347d4 100644
--- a/addons/web/static/src/js/services/ajax_service.js
+++ b/addons/web/static/src/js/services/ajax_service.js
@@ -6,8 +6,18 @@ var session = require('web.session');
var AjaxService = AbstractService.extend({
name: 'ajax',
- rpc: function (route, args, options) {
- return session.rpc(route, args, options);
+ rpc: function (route, args, options, target) {
+ return $.Deferred(function (def) {
+ session.rpc(route, args, options).then(function () {
+ if (!target.isDestroyed()) {
+ def.resolve.apply(def, arguments);
+ }
+ }, function () {
+ if (!target.isDestroyed()) {
+ def.reject.apply(def, arguments);
+ }
+ });
+ }).promise();
},
});