From b8180f4c09995a76e5f1e6ca1ff868a9bdff7d31 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 8 Jan 2013 17:41:04 +0100 Subject: [PATCH] [FIX] problem when multiple instances of the web client run in tabs and we disconnect from one tab, now displays a better error message lp bug: https://launchpad.net/bugs/1093671 fixed bzr revid: nicolas.vanhoren@openerp.com-20130108164104-7wv2yxlrczqmicvb --- addons/web/session.py | 5 +++++ addons/web/static/src/js/chrome.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/addons/web/session.py b/addons/web/session.py index fa99f58afa8..30e9308d4e1 100644 --- a/addons/web/session.py +++ b/addons/web/session.py @@ -18,6 +18,9 @@ _logger = logging.getLogger(__name__) class AuthenticationError(Exception): pass +class SessionExpiredException(Exception): + pass + class Service(object): def __init__(self, session, service_name): self.session = session @@ -152,6 +155,8 @@ class OpenERPSession(object): :type model: str :rtype: a model object """ + if self._db == False: + raise SessionExpiredException("Session expired") return Model(self, model) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 26d30ea98a2..30a51026684 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -247,6 +247,11 @@ instance.web.CrashManager = instance.web.Class.extend({ if (!this.active) { return; } + // yes, exception handling is shitty + if (error.code === 300 && error.data && error.data.type == "client_exception" && error.data.debug.match("SessionExpiredException")) { + this.show_warning({type: "Session Expired", data: { fault_code: "Your OpenERP session expired. Please refresh the current web page." }}); + return; + } if (error.data.fault_code) { var split = ("" + error.data.fault_code).split('\n')[0].split(' -- '); if (split.length > 1) {