[FIX] website: multi website and company switcher
Remove domain based Use domain if set That will imply that you need to reconnect on your new website too. task-1878245
This commit is contained in:
@@ -244,19 +244,19 @@ class View(models.Model):
|
||||
if 'main_object' not in qcontext:
|
||||
qcontext['main_object'] = self
|
||||
|
||||
domain_based_info = {'website_id': '', 'name': _('Domain Based')}
|
||||
force_website_id = request.session.get('force_website_id', False)
|
||||
if force_website_id:
|
||||
selected_website = Website.browse(force_website_id)
|
||||
qcontext['multi_website_selected_website'] = {'website_id': selected_website.id, 'name': selected_website.name}
|
||||
else:
|
||||
qcontext['multi_website_selected_website'] = domain_based_info
|
||||
cur = Website.get_current_website()
|
||||
qcontext['multi_website_websites_current'] = {'website_id': cur.id, 'name': cur.name, 'domain': cur.domain}
|
||||
qcontext['multi_website_websites'] = [
|
||||
{'website_id': website.id, 'name': website.name, 'domain': website.domain}
|
||||
for website in Website.search([]) if website != cur
|
||||
]
|
||||
|
||||
qcontext['multi_website_websites'] = [{'website_id': website.id, 'name': website.name} for website in Website.search([])]
|
||||
qcontext['multi_website_websites'] += [domain_based_info]
|
||||
|
||||
qcontext['multi_website_companies'] = [{'company_id': comp.id, 'name': comp.name} for comp in self.env.user.company_ids]
|
||||
qcontext['multi_website_current_company'] = {'company_id': self.env.user.company_id.id, 'name': self.env.user.company_id.name}
|
||||
cur_company = self.env.user.company_id
|
||||
qcontext['multi_website_companies_current'] = {'company_id': cur_company.id, 'name': cur_company.name}
|
||||
qcontext['multi_website_companies'] = [
|
||||
{'company_id': comp.id, 'name': comp.name}
|
||||
for comp in self.env.user.company_ids if comp != cur_company
|
||||
]
|
||||
|
||||
qcontext.update(dict(
|
||||
self._context.copy(),
|
||||
|
||||
@@ -304,14 +304,29 @@ var WebsiteRoot = BodyManager.extend({
|
||||
*/
|
||||
_multiWebsiteSwitch: function (ev) {
|
||||
var website_id_to_switch_to = 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
|
||||
|
||||
this._rpc({
|
||||
route: '/website/force_website',
|
||||
params: {
|
||||
website_id: website_id_to_switch_to || false,
|
||||
},
|
||||
}).then(function () {
|
||||
window.location.reload(true);
|
||||
var website_domain = ev.currentTarget.getAttribute('domain');
|
||||
if (website_domain && window.location.hostname !== website_domain) {
|
||||
// if domain unchanged, this line will do a nop while we need to refresh
|
||||
// the page to load the new forced website.
|
||||
window.location.hostname = website_domain;
|
||||
}
|
||||
else {
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
_multiCompanySwitch: function (ev) {
|
||||
|
||||
@@ -77,12 +77,11 @@
|
||||
<li class="o_mobile_preview" id="mobile-menu">
|
||||
<a data-action="show-mobile-preview" href="#"><span title="Mobile preview" role="img" aria-label="Mobile preview" class="fa fa-mobile"/></a>
|
||||
</li>
|
||||
<li t-if="user_id.has_group('base.group_multi_company') and user_id.has_group('website.group_multi_website') and len(multi_website_companies) > 1">
|
||||
<a class="dropdown-toggle waves" data-toggle="dropdown" href="#"><t t-esc="multi_website_current_company['name']"/></a>
|
||||
<li t-if="user_id.has_group('base.group_multi_company') and user_id.has_group('website.group_multi_website') and len(multi_website_companies)">
|
||||
<a class="dropdown-toggle waves" data-toggle="dropdown" href="#"><t t-esc="multi_website_companies_current['name']"/></a>
|
||||
<div class="dropdown-menu" role="menu">
|
||||
<t t-foreach="multi_website_companies" t-as="multi_website_company">
|
||||
<a role="menuitem" href="#"
|
||||
t-if="multi_website_current_company['company_id'] != multi_website_company['company_id']"
|
||||
class="dropdown-item oe_menu_text js_multi_company_switch"
|
||||
t-att-company-id="str(multi_website_company['company_id'])"
|
||||
>
|
||||
@@ -92,11 +91,11 @@
|
||||
</div>
|
||||
</li>
|
||||
<li groups="website.group_multi_website">
|
||||
<a class="dropdown-toggle waves" data-toggle="dropdown" href="#"><t t-esc="multi_website_selected_website['name']"/></a>
|
||||
<a class="dropdown-toggle waves" data-toggle="dropdown" href="#"><t t-esc="multi_website_websites_current['name']"/></a>
|
||||
<div class="dropdown-menu" role="menu">
|
||||
<t t-foreach="multi_website_websites" t-as="multi_website_website">
|
||||
<a role="menuitem" href="#"
|
||||
t-if="multi_website_selected_website['website_id'] != multi_website_website['website_id']"
|
||||
t-att-domain="multi_website_website['domain']"
|
||||
class="dropdown-item oe_menu_text js_multi_website_switch"
|
||||
t-att-website-id="str(multi_website_website['website_id'])"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user