diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-06-15 10:15:27 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-06-15 10:15:27 +0200 |
| commit | b170a753e18c96f59e8c99a4e1750a4b85628338 (patch) | |
| tree | 13c365d5e3db51e3b94def4e88968170743ce7ae /addons/web/static/src/js/core/session.js | |
| parent | a3c9c286cc46e03040e954f7872ade3555d98ad9 (diff) | |
| parent | b05e4d5f958892a9ff644b28a4ee165aeb2ea247 (diff) | |
[MERGE] forward port branch 11.0 up to b05e4d5f958
Diffstat (limited to 'addons/web/static/src/js/core/session.js')
| -rw-r--r-- | addons/web/static/src/js/core/session.js | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js index 4760867e99f..cc372877e6d 100644 --- a/addons/web/static/src/js/core/session.js +++ b/addons/web/static/src/js/core/session.js @@ -49,6 +49,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { this.qweb_mutex = new concurrency.Mutex(); this.currencies = {}; this._groups_def = {}; + core.bus.on('invalidate_session', this, this._onInvalidateSession); }, setup: function (origin, options) { // must be able to customize server @@ -327,23 +328,17 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { rpc: function (url, params, options) { var self = this; options = _.clone(options || {}); - var shadow = options.shadow || false; options.headers = _.extend({}, options.headers); if (odoo.debug) { options.headers["X-Debug-Mode"] = $.deparam($.param.querystring()).debug; } - delete options.shadow; - return self.check_session_id().then(function () { // TODO: remove if (! _.isString(url)) { _.extend(options, url); url = url.url; } - // TODO correct handling of timeouts - if (! shadow) - self.trigger('request'); var fct; if (self.origin_server) { fct = ajax.jsonRpc; @@ -362,37 +357,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { url = self.url(url, null); options.session_id = self.session_id || ''; } - var p = fct(url, "call", params, options); - p = p.then(function (result) { - if (! shadow) - self.trigger('response'); - return result; - }, function (type, error, textStatus, errorThrown) { - if (type === "server") { - if (! shadow) - self.trigger('response'); - if (error.code === 100) { - self.uid = false; - } - return $.Deferred().reject(error, $.Event()); - } else { - if (! shadow) - self.trigger('response_failed'); - var nerror = { - code: -32098, - message: "XmlHttpRequestError " + errorThrown, - data: {type: "xhr"+textStatus, debug: error.responseText, objects: [error, errorThrown] } - }; - return $.Deferred().reject(nerror, $.Event()); - } - }); - return p.fail(function () { // Allow deferred user to disable rpc_error call in fail - p.fail(function (error, event) { - if (!event.isDefaultPrevented()) { - self.trigger('error', error, event); - } - }); - }); + return fct(url, "call", params, options); }); }, url: function (path, params) { @@ -418,6 +383,17 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { getTZOffset: function (date) { return -new Date(date).getTimezoneOffset(); }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + */ + _onInvalidateSession: function () { + this.uid = false; + }, }); return Session; |
