summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/services
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-09-14 16:00:17 +0200
committerChristophe Simonis <chs@odoo.com>2018-09-14 16:00:17 +0200
commit9c77066f345360429a0920ca4d17af1f84a7ebea (patch)
tree469494018b2da134a8ddb5f51930566c1d39bf8e /addons/web/static/src/js/services
parent5c11e0d6f9dcc2161735ce3fb93430b767d54cf9 (diff)
parent6c103589c15dcf97603f3e2909871cb1fefd6484 (diff)
[MERGE] forward port branch saas-11.4 up to 6c103589c15
Diffstat (limited to 'addons/web/static/src/js/services')
-rw-r--r--addons/web/static/src/js/services/ajax_service.js25
1 files changed, 14 insertions, 11 deletions
diff --git a/addons/web/static/src/js/services/ajax_service.js b/addons/web/static/src/js/services/ajax_service.js
index bf754792932..0cecaae9da3 100644
--- a/addons/web/static/src/js/services/ajax_service.js
+++ b/addons/web/static/src/js/services/ajax_service.js
@@ -7,17 +7,20 @@ var session = require('web.session');
var AjaxService = AbstractService.extend({
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();
+ var def = $.Deferred();
+ var promise = def.promise();
+ var xhrDef = session.rpc(route, args, options);
+ promise.abort = xhrDef.abort.bind(xhrDef);
+ xhrDef.then(function () {
+ if (!target.isDestroyed()) {
+ def.resolve.apply(def, arguments);
+ }
+ }).fail(function () {
+ if (!target.isDestroyed()) {
+ def.reject.apply(def, arguments);
+ }
+ });
+ return promise;
},
});