diff options
| author | Sébastien Theys <seb@odoo.com> | 2019-09-05 14:53:16 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2019-09-05 14:53:16 +0000 |
| commit | c6bb103eac3cc645ce6053bf875b768a2b3bbd3a (patch) | |
| tree | 84dc0f5f1aec506d9e45bf51bb92b1b0f32a0165 /addons | |
| parent | 3cadfebf0fe7a8b9d410ecc80ac935d1f05283e5 (diff) | |
[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>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/website/models/ir_ui_view.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 2f1b4c8d17e..2dc67c1d8c6 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -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 - ] - - 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 - ] + 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 + ] qcontext.update(dict( self._context.copy(), |
