From ca449f01f8ddff291c783c7e8d5eca602428bd68 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 30 Aug 2022 12:09:14 +0000 Subject: [PATCH] [FIX] test_themes: force request's website before _frontend_pre_dispatch The callstack is: - _pre_dispatch() (http_routing) - super() - _frontend_pre_dispatch() - super() - _frontend_pre_dispatch() (website) -> Set the website on request But in `test_themes` we were forcing the website in a `_pre_dispatch()` override, after calling `super()`. It means that the call to `_frontend_pre_dispatch()` was actually done without having yet forced the website in session. get_current_website() would then not consider the `fw` param as not yet in session, and the request.website would be set to 1, the default one. Later in the business code, there would be a mismatch between `request.website` and `get_current_website()`. closes odoo/design-themes#582 Related: odoo/odoo#98200 Related: odoo/enterprise#30691 Related: odoo/upgrade#3808 Signed-off-by: Quentin Smetz (qsm) --- test_themes/models/ir_http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_themes/models/ir_http.py b/test_themes/models/ir_http.py index 3eb24d069..cce730aca 100644 --- a/test_themes/models/ir_http.py +++ b/test_themes/models/ir_http.py @@ -10,9 +10,9 @@ class Http(models.AbstractModel): @classmethod def _pre_dispatch(cls, rule, args): - super()._pre_dispatch(rule, args) - # Allow public user to use `fw` query string in test mode to ease tests force_website_id = request.httprequest.args.get('fw') if (request.registry.in_test_mode() or tools.config.options['test_enable']) and force_website_id: request.env['website']._force_website(force_website_id) + + super()._pre_dispatch(rule, args)