diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index 4779f84ce27..0cc3bd44cb2 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -16,9 +16,13 @@ class PortalAccount(CustomerPortal): 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(self._get_invoices_domain()) \ + invoice_count = request.env['account.move'].search_count(self._get_invoices_domain('in'), limit=1) \ if request.env['account.move'].check_access_rights('read', raise_exception=False) else 0 values['invoice_count'] = invoice_count + if 'bill_count' in counters: + bill_count = request.env['account.move'].search_count(self._get_invoices_domain('out'), limit=1) \ + if request.env['account.move'].check_access_rights('read', raise_exception=False) else 0 + values['bill_count'] = bill_count return values # ------------------------------------------------------------ @@ -32,8 +36,12 @@ class PortalAccount(CustomerPortal): } return self._get_page_view_values(invoice, access_token, values, 'my_invoices_history', False, **kwargs) - def _get_invoices_domain(self): - return [('state', 'not in', ('cancel', 'draft')), ('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))] + def _get_invoices_domain(self, m_type=None): + if m_type in ['in', 'out']: + move_type = [m_type+move for move in ('_invoice', '_refund', '_receipt')] + else: + move_type = ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt') + return [('state', 'not in', ('cancel', 'draft')), ('move_type', 'in', move_type)] def _get_account_searchbar_sortings(self): return { @@ -46,8 +54,8 @@ class PortalAccount(CustomerPortal): def _get_account_searchbar_filters(self): return { 'all': {'label': _('All'), 'domain': []}, - 'invoices': {'label': _('Invoices'), 'domain': [('move_type', 'in', ('out_invoice', 'out_refund'))]}, - 'bills': {'label': _('Bills'), 'domain': [('move_type', 'in', ('in_invoice', 'in_refund'))]}, + 'invoices': {'label': _('Invoices'), 'domain': [('move_type', 'in', ('out_invoice', 'out_refund', 'out_receipt'))]}, + 'bills': {'label': _('Bills'), 'domain': [('move_type', 'in', ('in_invoice', 'in_refund', 'in_receipt'))]}, } @http.route(['/my/invoices', '/my/invoices/page/'], type='http', auth="user", website=True) diff --git a/addons/account/static/src/img/Bill.svg b/addons/account/static/src/img/Bill.svg new file mode 100644 index 00000000000..51d1968db63 --- /dev/null +++ b/addons/account/static/src/img/Bill.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/addons/account/views/account_portal_templates.xml b/addons/account/views/account_portal_templates.xml index 51e7c70c7f5..18d680dd7bd 100644 --- a/addons/account/views/account_portal_templates.xml +++ b/addons/account/views/account_portal_templates.xml @@ -13,13 +13,28 @@