[IMP] website: avoid computing multi_website_ qcontext if not useful
Those values are only used on the website navbar when the user is in both groups so the vast majority of the time they are done for no reason. This reduces the number of queries by 2 on every page when the user is not admin and/or multi website is not enabled. Part of task-2061122 closes odoo/odoo#36483 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
@@ -331,18 +331,19 @@ class View(models.Model):
|
||||
qcontext['main_object'] = self
|
||||
|
||||
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
|
||||
]
|
||||
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'] = [
|
||||
{'website_id': website.id, 'name': website.name, 'domain': website.domain}
|
||||
for website in Website.search([]) if website != cur
|
||||
]
|
||||
|
||||
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
|
||||
]
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user