summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2018-04-25 12:25:45 +0200
committerChristophe Matthieu <chm@odoo.com>2018-08-09 02:31:59 +0200
commit693c771111eb7fa6edaaa36bb86f3df64cc6b9ba (patch)
tree5925bfa18820a3545b6f8a3b189ed8647839e59e /addons/web/static/src/js/core
parent23c0c791288bf132171eeeb43af54b8f12d5b880 (diff)
[IMP] web: abord the poll when destroy to avoid useless call
If the service bus are called and destroyed the rpc can be returned after, to avoid a useless call to the database and unexpected behavior, we abort the connection.
Diffstat (limited to 'addons/web/static/src/js/core')
-rw-r--r--addons/web/static/src/js/core/service_mixins.js6
-rw-r--r--addons/web/static/src/js/core/session.js4
2 files changed, 7 insertions, 3 deletions
diff --git a/addons/web/static/src/js/core/service_mixins.js b/addons/web/static/src/js/core/service_mixins.js
index d1868c98d1f..850e9983a74 100644
--- a/addons/web/static/src/js/core/service_mixins.js
+++ b/addons/web/static/src/js/core/service_mixins.js
@@ -127,8 +127,10 @@ var ServicesMixin = {
*/
_rpc: function (params, options) {
var query = rpc.buildQuery(params);
- var def = this.call('ajax', 'rpc', query.route, query.params, options);
- return def ? def.promise() : $.Deferred().promise();
+ var def = this.call('ajax', 'rpc', query.route, query.params, options) || $.Deferred();
+ var promise = def.promise();
+ promise.abort = def.abort ? def.abort.bind(def) : function abort () {def.reject();};
+ return promise;
},
loadFieldView: function (dataset, view_id, view_type, options) {
return this.loadViews(dataset.model, dataset.get_context().eval(), [[view_id, view_type]], options).then(function (result) {
diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js
index 09b65357404..fcbc5872be0 100644
--- a/addons/web/static/src/js/core/session.js
+++ b/addons/web/static/src/js/core/session.js
@@ -346,7 +346,9 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
return deferred.then(function () {
if (aborted) {
- return $.Deferred().reject('communication', $.Event(), 'abort', 'abort');
+ var def = $.Deferred().reject('communication', $.Event(), 'abort', 'abort');
+ def.abort = function () {};
+ return def;
}
// TODO: remove
if (! _.isString(url)) {