Skip to content
Snippets Groups Projects
Commit 9894b36e authored by Romain Derie's avatar Romain Derie
Browse files

[FIX] website: prevent crash when 'force_website_id' has been deleted

As an admin or website publisher, you have the possibility to switch website in
the navbar. This will force a website in your session*.

If this website is removed at some point, your session will be broken as the
dispatch will lead to a traceback, trying to read un unexisting website.

* There is other way to have the website forced in the session: theme install,
  go to website from settings, create website from settings..

opw-2092845

X-original-commit: 835d1201
parent 0ac7d67c
Branches
Tags
No related merge requests found
......@@ -519,7 +519,12 @@ class Website(models.Model):
@api.model
def get_current_website(self, fallback=True):
if request and request.session.get('force_website_id'):
return self.browse(request.session['force_website_id'])
website_id = self.browse(request.session['force_website_id']).exists()
if not website_id:
# Don't crash is session website got deleted
request.session.pop('force_website_id')
else:
return website_id
website_id = self.env.context.get('website_id')
if website_id:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment