diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 4b5b3a3fa3a..5440052ba6e 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -331,9 +331,9 @@ class View(models.Model): cur = Website.get_current_website() if self.env.user.has_group('website.group_website_publisher') and self.env.user.has_group('website.group_multi_website'): - qcontext['multi_website_websites_current'] = {'website_id': cur.id, 'name': cur.name, 'domain': cur.domain} + qcontext['multi_website_websites_current'] = {'website_id': cur.id, 'name': cur.name, 'domain': cur._get_http_domain()} qcontext['multi_website_websites'] = [ - {'website_id': website.id, 'name': website.name, 'domain': website.domain} + {'website_id': website.id, 'name': website.name, 'domain': website._get_http_domain()} for website in Website.search([]) if website != cur ] diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index dc2b2f679d7..22363f04129 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -182,21 +182,14 @@ var WebsiteRoot = publicRootData.PublicRoot.extend({ * @param {Event} ev */ _onWebsiteSwitch: function (ev) { - var websiteID = ev.currentTarget.getAttribute('website-id'); - - // need to force in each case, even if domain is set - // Website 1: localhost; Website 2: 0.0.0.0; website 3: - - // when you switch 3 <--> 1, you need to force the website - + var websiteId = ev.currentTarget.getAttribute('website-id'); var websiteDomain = ev.currentTarget.getAttribute('domain'); - var url = $.param.querystring(window.location.href, {fw: websiteID}); + var url = window.location.href; if (websiteDomain && window.location.hostname !== websiteDomain) { - // if domain unchanged, this line will do a nop while we need to refresh - // the page to load the new forced website. - url = new URL(url); - url.hostname = websiteDomain; + var path = window.location.pathname + window.location.search + window.location.hash; + url = websiteDomain + path; } - window.location.href = url; + window.location.href = $.param.querystring(url, {'fw': websiteId}); }, /** * @private