[FIX] account: avoid error when internal user (no accounting

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) <wan@odoo.com>
This commit is contained in:
Roy Le
2023-10-19 07:23:42 +00:00
parent 5f586a50b4
commit b726842e47
+6 -2
View File
@@ -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,
},