[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

closes odoo/odoo#56859

X-original-commit: e75086000ee4317b2ad2994db5d906fbcbd5081f
Related: odoo/enterprise#12830
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2020-09-01 10:30:32 +00:00
committed by Thibault Delavallée
parent 594ccdcbf4
commit 2da7bc2adb
7 changed files with 4 additions and 63 deletions
-2
View File
@@ -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,
-20
View File
@@ -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):
-21
View File
@@ -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']}&amp;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>
+1 -6
View File
@@ -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,
-2
View File
@@ -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())),
+1 -5
View File
@@ -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,
@@ -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,