[IMP] website: perf - reduce query for editor on first blank page
Before this commit, the template to generate 'New' panel generates .exists() queries for each env.ref, now only one by module. We could still improve it, deferring this rendering on click only. For now, each time you are editor, we render it, even if you don't plan to create anything. + use some xmlid_to_res_id instead of ref to avoid useless exists query. Courtesy of @Feyensv for the tips
This commit is contained in:
@@ -395,7 +395,7 @@ class View(models.Model):
|
||||
if values and 'main_object' in values:
|
||||
if request.env.user.has_group('website.group_website_publisher'):
|
||||
func = getattr(values['main_object'], 'get_backend_menu_id', False)
|
||||
values['backend_menu_id'] = func and func() or self.env.ref('website.menu_website_configuration').id
|
||||
values['backend_menu_id'] = func and func() or self.env['ir.model.data'].xmlid_to_res_id('website.menu_website_configuration')
|
||||
|
||||
if self._context != new_context:
|
||||
self = self.with_context(new_context)
|
||||
|
||||
@@ -109,54 +109,78 @@
|
||||
<p>Page</p>
|
||||
</a>
|
||||
</div>
|
||||
<div groups="base.group_system" name="module_website_blog" t-att-data-module-id="env.ref('base.module_website_blog').id" t-att-data-module-shortdesc="env.ref('base.module_website_blog').shortdesc" class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_blog_post">
|
||||
<i class="fa fa-rss"/>
|
||||
<p>Blog Post</p>
|
||||
</a>
|
||||
</div>
|
||||
<div groups="base.group_system" name="module_website_event" t-att-data-module-id="env.ref('base.module_website_event').id" t-att-data-module-shortdesc="env.ref('base.module_website_event').shortdesc" class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_event">
|
||||
<i class="fa fa-glass"/>
|
||||
<p>Event</p>
|
||||
</a>
|
||||
</div>
|
||||
<div groups="base.group_system" name="module_website_forum"
|
||||
t-att-data-module-id="env.ref('base.module_website_forum').id"
|
||||
t-att-data-module-shortdesc="env.ref('base.module_website_forum').shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element o_new_content_element_once">
|
||||
<a href="#" data-url="/forum" data-action="new_forum">
|
||||
<i class="fa fa-comment"/>
|
||||
<p>Forum</p>
|
||||
</a>
|
||||
</div>
|
||||
<div groups="base.group_system" name="module_website_hr_recruitment" t-att-data-module-id="env.ref('base.module_website_hr_recruitment').id" t-att-data-module-shortdesc="env.ref('base.module_website_hr_recruitment').shortdesc" class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#">
|
||||
<i class="fa fa-briefcase"/>
|
||||
<p>Job Offer</p>
|
||||
</a>
|
||||
</div>
|
||||
<div groups="base.group_system" name="module_website_sale" t-att-data-module-id="env.ref('base.module_website_sale').id" t-att-data-module-shortdesc="env.ref('base.module_website_sale').shortdesc" class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_product">
|
||||
<i class="fa fa-shopping-cart"/>
|
||||
<p>Product</p>
|
||||
</a>
|
||||
</div>
|
||||
<div groups="base.group_system" name="module_website_slides" t-att-data-module-id="env.ref('base.module_website_slides').id" t-att-data-module-shortdesc="env.ref('base.module_website_slides').shortdesc" class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_slide_channel">
|
||||
<i class="fa fa-graduation-cap"></i>
|
||||
<p>Course</p>
|
||||
</a>
|
||||
</div>
|
||||
<div groups="base.group_system" name="module_website_livechat"
|
||||
t-att-data-module-id="env.ref('base.module_website_livechat').id"
|
||||
t-att-data-module-shortdesc="env.ref('base.module_website_livechat').shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element o_new_content_element_once">
|
||||
<a href="#" data-url="/livechat" data-action="new_channel">
|
||||
<i class="fa fa-hashtag"/>
|
||||
<p>Livechat Widget</p>
|
||||
</a>
|
||||
</div>
|
||||
<t groups="base.group_system">
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_blog')"/>
|
||||
<div name="module_website_blog"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_blog_post">
|
||||
<i class="fa fa-rss"/>
|
||||
<p>Blog Post</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_event')"/>
|
||||
<div name="module_website_event"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_event">
|
||||
<i class="fa fa-glass"/>
|
||||
<p>Event</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_forum')"/>
|
||||
<div name="module_website_forum"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element o_new_content_element_once">
|
||||
<a href="#" data-url="/forum" data-action="new_forum">
|
||||
<i class="fa fa-comment"/>
|
||||
<p>Forum</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_hr_recruitment')"/>
|
||||
<div name="module_website_hr_recruitment"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#">
|
||||
<i class="fa fa-briefcase"/>
|
||||
<p>Job Offer</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_sale')"/>
|
||||
<div name="module_website_sale"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_product">
|
||||
<i class="fa fa-shopping-cart"/>
|
||||
<p>Product</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_slides')"/>
|
||||
<div name="module_website_slides"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_slide_channel">
|
||||
<i class="fa fa-graduation-cap"></i>
|
||||
<p>Course</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_livechat')"/>
|
||||
<div name="module_website_livechat"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element o_new_content_element_once">
|
||||
<a href="#" data-url="/livechat" data-action="new_channel">
|
||||
<i class="fa fa-hashtag"/>
|
||||
<p>Livechat Widget</p>
|
||||
</a>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -702,7 +702,7 @@
|
||||
<button type="button" t-attf-class="btn btn-default dropdown-toggle dropdown-toggle-split" t-att-id="'dopprod-%s' % object.id" data-toggle="dropdown"/>
|
||||
<div class="dropdown-menu" role="menu" t-att-aria-labelledby="'dopprod-%s' % object.id">
|
||||
<t t-raw="0"/>
|
||||
<a role="menuitem" t-attf-href="/web#view_type=form&model=#{object._name}&id=#{object.id}&action=#{action}&menu_id=#{menu or object.env.ref('website.menu_website_configuration').id}"
|
||||
<a role="menuitem" t-attf-href="/web#view_type=form&model=#{object._name}&id=#{object.id}&action=#{action}&menu_id=#{menu or object.env['ir.model.data'].xmlid_to_res_id('website.menu_website_configuration')}"
|
||||
title='Edit in backend' class="dropdown-item" t-if="publish_edit">Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user