diff options
| author | Victor Feyens <vfe@odoo.com> | 2020-08-12 09:32:28 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-09-01 07:18:06 +0000 |
| commit | e75086000ee4317b2ad2994db5d906fbcbd5081f (patch) | |
| tree | 54945426c1770ae46e10f99440105a288a7ec07f | |
| parent | b0e0035b585f976e912e97e7f95f66b525bc8e43 (diff) | |
[REM] portal, *: remove archive_groups dead code
PURPOSE
Clean code and be and more performance oriented.
SPECIFICATIONS
Various portal pages hold references to archive_groups. It was a summary
of customer documents for portal, containing a count of all documents split
by model.
Currently its computation is not used. Indeed archive_groups is displayed
only in 'my_details' page that does not hold any document-based reference
or code call. Other calls to archive_groups are dead code as the result is
not used. Since 13.0 it is even not computed on standard pages to speedup
their load (as it was not used).
It is not used anymore and its computation and references can be removed
safely, especially with v14 in mind for which we want to remove dead code
to maintain.
Followup of odoo/odoo#55228
LINKS
Task ID-2329081
PR odoo/odoo#55800
PR #12368
Related: odoo/enterprise#12368
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
| -rw-r--r-- | addons/account/controllers/portal.py | 2 | ||||
| -rw-r--r-- | addons/portal/controllers/portal.py | 20 | ||||
| -rw-r--r-- | addons/portal/views/portal_templates.xml | 21 | ||||
| -rw-r--r-- | addons/project/controllers/portal.py | 7 | ||||
| -rw-r--r-- | addons/purchase/controllers/portal.py | 2 | ||||
| -rw-r--r-- | addons/sale/controllers/portal.py | 6 | ||||
| -rw-r--r-- | addons/website_crm_partner_assign/controllers/main.py | 9 |
7 files changed, 4 insertions, 63 deletions
diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index 8723334ffcd..9766b27c276 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -58,7 +58,6 @@ class PortalAccount(CustomerPortal): filterby = 'all' domain += searchbar_filters[filterby]['domain'] - archive_groups = self._get_archive_groups('account.move', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] @@ -81,7 +80,6 @@ class PortalAccount(CustomerPortal): 'invoices': invoices, 'page_name': 'invoice', 'pager': pager, - 'archive_groups': archive_groups, 'default_url': '/my/invoices', 'searchbar_sortings': searchbar_sortings, 'sortby': sortby, diff --git a/addons/portal/controllers/portal.py b/addons/portal/controllers/portal.py index c2c7901030b..548b72ef8e4 100644 --- a/addons/portal/controllers/portal.py +++ b/addons/portal/controllers/portal.py @@ -123,25 +123,6 @@ class CustomerPortal(Controller): _items_per_page = 20 - def _get_archive_groups(self, model, domain=None, fields=None, groupby="create_date", order="create_date desc"): - if not model: - return [] - if domain is None: - domain = [] - if fields is None: - fields = ['name', 'create_date'] - groups = [] - for group in request.env[model]._read_group_raw(domain, fields=fields, groupby=groupby, orderby=order): - dates, label = group[groupby] - date_begin, date_end = dates.split('/') - groups.append({ - 'date_begin': odoo_fields.Date.to_string(odoo_fields.Date.from_string(date_begin)), - 'date_end': odoo_fields.Date.to_string(odoo_fields.Date.from_string(date_end)), - 'name': label, - 'item_count': group[groupby + '_count'] - }) - return groups - def _prepare_portal_layout_values(self): """Values for /my/* templates rendering. @@ -156,7 +137,6 @@ class CustomerPortal(Controller): return { 'sales_user': sales_user, 'page_name': 'home', - 'archive_groups': [], } def _prepare_home_portal_values(self, counters): diff --git a/addons/portal/views/portal_templates.xml b/addons/portal/views/portal_templates.xml index 6f1c5b60dc9..02a8d10301b 100644 --- a/addons/portal/views/portal_templates.xml +++ b/addons/portal/views/portal_templates.xml @@ -132,9 +132,6 @@ <hr class="mt-1 mb-1"/> <a href="/my/security"><i class="fa fa-pencil mx-1"/>Edit Security Settings</a> </div> - <div class="o_my_archives" t-if="archive_groups"> - <t t-call="portal.portal_archive_groups"/> - </div> </div> </div> </t> @@ -351,24 +348,6 @@ </div> </template> - <template id="portal_archive_groups" name="Portal Archive Groups"> - <h3 class="o_page_header">Archives</h3> - <ul class="nav nav-pills flex-column"> - <t t-foreach="archive_groups" t-as="group"> - <t t-if="group['date_begin'] == date"> - <li class="nav-item"> - <a t-att-href="default_url" class="nav-link active" t-ignore="True"><t t-esc="group['name']"/><span class="float-right badge badge-pill" t-esc="group['item_count']"/></a> - </li> - </t> - <t t-if="group['date_begin'] != date"> - <li class="nav-item"> - <a t-ignore="True" t-attf-href="#{default_url}?date_begin=#{group['date_begin']}&date_end=#{group['date_end']}" class="nav-link"><t t-esc="group['name']"/><span class="float-right badge badge-pill" t-esc="group['item_count']"/></a> - </li> - </t> - </t> - </ul> - </template> - <template id="portal_my_details"> <t t-call="portal.portal_layout"> <t t-set="additional_title">Contact Details</t> diff --git a/addons/project/controllers/portal.py b/addons/project/controllers/portal.py index f7480d3aedb..e80aaa647e2 100644 --- a/addons/project/controllers/portal.py +++ b/addons/project/controllers/portal.py @@ -47,10 +47,9 @@ class CustomerPortal(CustomerPortal): sortby = 'date' order = searchbar_sortings[sortby]['order'] - # archive groups - Default Group By 'create_date' - archive_groups = self._get_archive_groups('project.project', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] + # projects count project_count = Project.search_count(domain) # pager @@ -71,7 +70,6 @@ class CustomerPortal(CustomerPortal): 'date_end': date_end, 'projects': projects, 'page_name': 'project', - 'archive_groups': archive_groups, 'default_url': '/my/projects', 'pager': pager, 'searchbar_sortings': searchbar_sortings, @@ -159,8 +157,6 @@ class CustomerPortal(CustomerPortal): if not groupby: groupby = 'project' - # archive groups - Default Group By 'create_date' - archive_groups = self._get_archive_groups('project.task', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] @@ -210,7 +206,6 @@ class CustomerPortal(CustomerPortal): 'date_end': date_end, 'grouped_tasks': grouped_tasks, 'page_name': 'task', - 'archive_groups': archive_groups, 'default_url': '/my/tasks', 'pager': pager, 'searchbar_sortings': searchbar_sortings, diff --git a/addons/purchase/controllers/portal.py b/addons/purchase/controllers/portal.py index ddecdf1cefb..8a264c19188 100644 --- a/addons/purchase/controllers/portal.py +++ b/addons/purchase/controllers/portal.py @@ -44,7 +44,6 @@ class CustomerPortal(CustomerPortal): domain = [] - archive_groups = self._get_archive_groups('purchase.order', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] @@ -93,7 +92,6 @@ class CustomerPortal(CustomerPortal): 'orders': orders, 'page_name': 'purchase', 'pager': pager, - 'archive_groups': archive_groups, 'searchbar_sortings': searchbar_sortings, 'sortby': sortby, 'searchbar_filters': OrderedDict(sorted(searchbar_filters.items())), diff --git a/addons/sale/controllers/portal.py b/addons/sale/controllers/portal.py index 969de29735d..a9c9fe94550 100644 --- a/addons/sale/controllers/portal.py +++ b/addons/sale/controllers/portal.py @@ -58,7 +58,6 @@ class CustomerPortal(CustomerPortal): sortby = 'date' sort_order = searchbar_sortings[sortby]['order'] - archive_groups = self._get_archive_groups('sale.order', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] @@ -81,7 +80,6 @@ class CustomerPortal(CustomerPortal): 'quotations': quotations.sudo(), 'page_name': 'quote', 'pager': pager, - 'archive_groups': archive_groups, 'default_url': '/my/quotes', 'searchbar_sortings': searchbar_sortings, 'sortby': sortby, @@ -109,7 +107,6 @@ class CustomerPortal(CustomerPortal): sortby = 'date' sort_order = searchbar_sortings[sortby]['order'] - archive_groups = self._get_archive_groups('sale.order', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] @@ -123,7 +120,7 @@ class CustomerPortal(CustomerPortal): page=page, step=self._items_per_page ) - # content according to pager and archive selected + # content according to pager orders = SaleOrder.search(domain, order=sort_order, limit=self._items_per_page, offset=pager['offset']) request.session['my_orders_history'] = orders.ids[:100] @@ -132,7 +129,6 @@ class CustomerPortal(CustomerPortal): 'orders': orders.sudo(), 'page_name': 'order', 'pager': pager, - 'archive_groups': archive_groups, 'default_url': '/my/orders', 'searchbar_sortings': searchbar_sortings, 'sortby': sortby, diff --git a/addons/website_crm_partner_assign/controllers/main.py b/addons/website_crm_partner_assign/controllers/main.py index d01ad9efa02..30223855dcf 100644 --- a/addons/website_crm_partner_assign/controllers/main.py +++ b/addons/website_crm_partner_assign/controllers/main.py @@ -57,10 +57,9 @@ class WebsiteAccount(CustomerPortal): sortby = 'date' order = searchbar_sortings[sortby]['order'] - # archive groups - Default Group By 'create_date' - archive_groups = self._get_archive_groups('crm.lead', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] + # pager lead_count = CrmLead.search_count(domain) pager = request.website.pager( @@ -77,7 +76,6 @@ class WebsiteAccount(CustomerPortal): 'date': date_begin, 'leads': leads, 'page_name': 'lead', - 'archive_groups': archive_groups, 'default_url': '/my/leads', 'pager': pager, 'searchbar_sortings': searchbar_sortings, @@ -123,8 +121,6 @@ class WebsiteAccount(CustomerPortal): if filterby == 'lost': CrmLead = CrmLead.with_context(active_test=False) - # archive groups - Default Group By 'create_date' - archive_groups = self._get_archive_groups('crm.lead', domain) if values.get('my_details') else [] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] # pager @@ -136,14 +132,13 @@ class WebsiteAccount(CustomerPortal): page=page, step=self._items_per_page ) - # content according to pager and archive selected + # content according to pager opportunities = CrmLead.search(domain, order=order, limit=self._items_per_page, offset=pager['offset']) values.update({ 'date': date_begin, 'opportunities': opportunities, 'page_name': 'opportunity', - 'archive_groups': archive_groups, 'default_url': '/my/opportunities', 'pager': pager, 'searchbar_sortings': searchbar_sortings, |
