summaryrefslogtreecommitdiff
path: root/addons/website_crm_partner_assign
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2020-08-17 13:27:23 +0000
committerJeremy Kersten <jke@odoo.com>2020-08-17 15:59:03 +0000
commit73b4e9b1b671690a9d235459a6127da3603083a3 (patch)
tree8a54c671bef30e3d27a70c2402e9dd571e449aa3 /addons/website_crm_partner_assign
parent5da1b96fbfda00af595fee747c9cbd76369a43c5 (diff)
[IMP] portal,*: /my counter async
Before this commit, the time to compute all counters was making the rendering of the portal page slow. Now the count is done in rpc after the loading of the page. Now you can decide which part you want to show on the portal, and only compute for these one. It is not because you have purchase installed for your internal process, that it means that your supplier use your portal and it avoid the computation for all end users. We parallelize the counters in arbitrary 3 rpcs. closes odoo/odoo#55999 Related: odoo/enterprise#12456 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website_crm_partner_assign')
-rw-r--r--addons/website_crm_partner_assign/controllers/main.py14
-rw-r--r--addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml8
2 files changed, 10 insertions, 12 deletions
diff --git a/addons/website_crm_partner_assign/controllers/main.py b/addons/website_crm_partner_assign/controllers/main.py
index 85bc2e7cc88..d01ad9efa02 100644
--- a/addons/website_crm_partner_assign/controllers/main.py
+++ b/addons/website_crm_partner_assign/controllers/main.py
@@ -32,14 +32,12 @@ class WebsiteAccount(CustomerPortal):
('type', '=', 'opportunity')
]
- def _prepare_home_portal_values(self):
- values = super(WebsiteAccount, self)._prepare_home_portal_values()
- lead_count = request.env['crm.lead'].search_count(self.get_domain_my_lead(request.env.user))
- opp_count = request.env['crm.lead'].search_count(self.get_domain_my_opp(request.env.user))
- values.update({
- 'lead_count': lead_count,
- 'opp_count': opp_count,
- })
+ def _prepare_home_portal_values(self, counters):
+ values = super()._prepare_home_portal_values(counters)
+ if 'lead_count' in counters:
+ values['lead_count'] = request.env['crm.lead'].search_count(self.get_domain_my_lead(request.env.user))
+ if 'opp_count' in counters:
+ values['opp_count'] = request.env['crm.lead'].search_count(self.get_domain_my_opp(request.env.user))
return values
@http.route(['/my/leads', '/my/leads/page/<int:page>'], type='http', auth="user", website=True)
diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml
index 4dee7a3b7a9..3ff7b69a97c 100644
--- a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml
+++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml
@@ -208,17 +208,17 @@
</xpath>
</template>
- <template id="portal_my_home_lead" name="Portal My Home : lead entries" inherit_id="portal.portal_my_home" priority="15">
+ <template id="portal_my_home_lead" name="Show Leads / Opps" customize_show="True" inherit_id="portal.portal_my_home" priority="15">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
- <t t-if="lead_count" t-call="portal.portal_docs_entry">
+ <t t-call="portal.portal_docs_entry">
<t t-set="title">Leads</t>
<t t-set="url" t-value="'/my/leads'"/>
- <t t-set="count" t-value="lead_count"/>
+ <t t-set="placeholder_count" t-value="'lead_count'"/>
</t>
<t t-call="portal.portal_docs_entry">
<t t-set="title">Opportunities</t>
<t t-set="url" t-value="'/my/opportunities'"/>
- <t t-set="count" t-value="opp_count"/>
+ <t t-set="placeholder_count" t-value="'opp_count'"/>
</t>
</xpath>
</template>