From 73b4e9b1b671690a9d235459a6127da3603083a3 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Mon, 17 Aug 2020 13:27:23 +0000 Subject: [PATCH] [IMP] portal,*: /my counter async MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/account/controllers/portal.py | 13 +++--- .../views/account_portal_templates.xml | 6 +-- addons/hr_timesheet/controllers/portal.py | 9 +++-- .../views/hr_timesheet_portal_templates.xml | 8 ++-- addons/portal/controllers/portal.py | 12 ++++-- addons/portal/models/ir_ui_view.py | 4 +- addons/portal/static/src/js/portal.js | 40 +++++++++++++++++++ addons/portal/views/portal_templates.xml | 9 ++++- addons/project/controllers/portal.py | 10 +++-- .../views/project_portal_templates.xml | 10 ++--- addons/purchase/controllers/portal.py | 12 +++--- addons/purchase/views/portal_templates.xml | 6 +-- addons/sale/controllers/portal.py | 26 ++++++------ addons/sale/views/sale_portal_templates.xml | 10 ++--- addons/website/models/ir_ui_view.py | 1 - .../controllers/main.py | 14 +++---- .../website_crm_partner_assign_templates.xml | 8 ++-- 17 files changed, 126 insertions(+), 72 deletions(-) diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index 6177008ca69..8723334ffcd 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -10,12 +10,13 @@ from odoo.http import request class PortalAccount(CustomerPortal): - def _prepare_home_portal_values(self): - values = super(PortalAccount, self)._prepare_home_portal_values() - invoice_count = request.env['account.move'].search_count([ - ('move_type', 'in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund', 'out_receipt', 'in_receipt')), - ]) - values['invoice_count'] = invoice_count + def _prepare_home_portal_values(self, counters): + values = super()._prepare_home_portal_values(counters) + if 'invoice_count' in counters: + invoice_count = request.env['account.move'].search_count([ + ('move_type', 'in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund', 'out_receipt', 'in_receipt')), + ]) + values['invoice_count'] = invoice_count return values # ------------------------------------------------------------ diff --git a/addons/account/views/account_portal_templates.xml b/addons/account/views/account_portal_templates.xml index a910e0db8c2..90c4604a4d6 100644 --- a/addons/account/views/account_portal_templates.xml +++ b/addons/account/views/account_portal_templates.xml @@ -12,12 +12,12 @@ - - - - - -