[FIX] website: make 'Go to website' redirect to correct website

Before this commit, 'Go to website' in website module dashboard might not
redirect to the correct website.
It would just redirect to `/` (href) without forcing the website selected in
the dashboard.

task-2063252
Closes #36390

closes odoo/odoo#37359

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Romain Derie
2019-09-24 13:59:23 +00:00
parent 964aa3d696
commit f8aba7b347
2 changed files with 15 additions and 3 deletions
+4 -2
View File
@@ -26,8 +26,10 @@ class WebsiteBackend(http.Controller):
current_website = website_id and Website.browse(website_id) or Website.get_current_website()
multi_website = request.env.user.has_group('website.group_multi_website')
dashboard_data['websites'] = (multi_website and request.env['website'].search([]) or current_website).read(['id', 'name'])
for website in dashboard_data['websites']:
websites = multi_website and request.env['website'].search([]) or current_website
dashboard_data['websites'] = websites.read(['id', 'name'])
for rec, website in zip(websites, dashboard_data['websites']):
website['domain'] = rec._get_http_domain()
if website['id'] == current_website.id:
website['selected'] = True
@@ -133,6 +133,12 @@ var Dashboard = AbstractAction.extend({
}).open();
},
on_go_to_website: function (ev) {
ev.preventDefault();
var website = _.findWhere(this.websites, {selected: true});
window.location.href = $.param.querystring(website.domain + '/', {'fw': website.id});
},
on_save_ga_client_id: function(ga_client_id, ga_analytics_key) {
var self = this;
return this._rpc({
@@ -393,10 +399,14 @@ var Dashboard = AbstractAction.extend({
self.on_website_button($(ev.target).data('website-id'));
});
}
var $buttons = $(QWeb.render("website.GoToButtons"));
$buttons.on('click', this.on_go_to_website.bind(this));
this.updateControlPanel({
cp_content: {
$searchview: this.$searchview,
$buttons: QWeb.render("website.GoToButtons"),
$buttons: $buttons,
},
});
},