diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index a0c9bf163cc..06f758f3cf1 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -13,9 +13,8 @@ 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([ - ('move_type', 'in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund', 'out_receipt', 'in_receipt')), - ]) if request.env['account.move'].check_access_rights('read', raise_exception=False) else 0 + invoice_count = request.env['account.move'].search_count(self._get_invoices_domain()) \ + if request.env['account.move'].check_access_rights('read', raise_exception=False) else 0 values['invoice_count'] = invoice_count return values @@ -30,12 +29,15 @@ class PortalAccount(CustomerPortal): } return self._get_page_view_values(invoice, access_token, values, 'my_invoices_history', False, **kwargs) + def _get_invoices_domain(self): + return [('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))] + @http.route(['/my/invoices', '/my/invoices/page/'], type='http', auth="user", website=True) def portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw): values = self._prepare_portal_layout_values() AccountInvoice = request.env['account.move'] - domain = [('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))] + domain = self._get_invoices_domain() searchbar_sortings = { 'date': {'label': _('Date'), 'order': 'invoice_date desc'},