From 2bb8b4ebfb33e26188d5f5e4b7380541d6618fe0 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 13 Feb 2014 14:42:19 +0100 Subject: [PATCH] [FIX] forward port ensure_db fix from saas-3 bzr revid: fme@openerp.com-20140213134219-pn5xmo5alxn1d57u --- addons/web/controllers/main.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 02a909c5c92..e463fec12e3 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -133,6 +133,20 @@ def ensure_db(redirect='/web/database/selector'): if db and db not in http.db_filter([db]): db = None + if db and not request.session.db: + # User asked a specific database on a new session. + # That mean the nodb router has been used to find the route + # Depending on installed module in the database, the rendering of the page + # may depend on data injected by the database route dispatcher. + # Thus, we redirect the user to the same page but with the session cookie set. + # This will force using the database route dispatcher... + r = request.httprequest + response = werkzeug.utils.redirect(r.url, 302) + request.session.db = db + response = r.app.get_response(r, response, explicit_session=False) + werkzeug.exceptions.abort(response) + return + # if db not provided, use the session one if not db: db = request.session.db