From b726842e472b5ad773f42a19db7b1bd8a9506786 Mon Sep 17 00:00:00 2001 From: Roy Le Date: Tue, 17 Oct 2023 13:38:15 +0700 Subject: [PATCH] [FIX] account: avoid error when internal user (no accounting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit permissions) see Invoices & Bills at /my/account Issue: Internal user cannot see their Invoices & Bills at portal without permissions in the accounting Fix: Verify that the read operation is allowed for the current user closes odoo/odoo#139141 X-original-commit: 5ebab949a06ec338cc28e912317a74bbfb3fe6ac Signed-off-by: William André (wan) --- addons/account/controllers/portal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index 91368e7bf36..0bc04fb9076 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -93,12 +93,16 @@ class PortalAccount(CustomerPortal): 'date': date_begin, # content according to pager and archive selected # lambda function to get the invoices recordset when the pager will be defined in the main method of a route - 'invoices': lambda pager_offset: AccountInvoice.search(domain, order=order, limit=self._items_per_page, offset=pager_offset), + 'invoices': lambda pager_offset: ( + AccountInvoice.search(domain, order=order, limit=self._items_per_page, offset=pager_offset) + if AccountInvoice.check_access_rights('read', raise_exception=False) else + AccountInvoice + ), 'page_name': 'invoice', 'pager': { # vals to define the pager. "url": url, "url_args": {'date_begin': date_begin, 'date_end': date_end, 'sortby': sortby}, - "total": AccountInvoice.search_count(domain), + "total": AccountInvoice.search_count(domain) if AccountInvoice.check_access_rights('read', raise_exception=False) else 0, "page": page, "step": self._items_per_page, },