From c3f593db78ea0c6144a83c046cb168af3383a7e1 Mon Sep 17 00:00:00 2001 From: Yenthe Van Ginneken Date: Mon, 27 Sep 2021 15:10:35 +0000 Subject: [PATCH] [FIX] account: allow overriding portal domain Before this commit the only way to modify the domain is to completely override portal_my_invoices. Since this function is so big this is not clean/easy to do. By creating a separate function we can simply override it and we can reuse the function on two places. closes odoo/odoo#77446 X-original-commit: b7effc442cd7ff47e00718adf5b1af43e9f326ee Signed-off-by: Florian Gilbert --- addons/account/controllers/portal.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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'},