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) {