[FIX] account, purchase, sale: portal access error
- Install account / purchase / sale - Ceate an internal user without any access rights - Go to `/my` A 500 error is raised because of an AccessError. When the user has no access rights to any of the mentioned applications, the `search` call returns an AccessError. We prevent the access error and return 0 as a fallback. opw-2367559 closes odoo/odoo#60849 X-original-commit: 54ef98c613219aba3bda41817f7767261b8092d2 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -15,7 +15,7 @@ class PortalAccount(CustomerPortal):
|
||||
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
|
||||
values['invoice_count'] = invoice_count
|
||||
return values
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class CustomerPortal(portal.CustomerPortal):
|
||||
if 'purchase_count' in counters:
|
||||
values['purchase_count'] = request.env['purchase.order'].search_count([
|
||||
('state', 'in', ['purchase', 'done', 'cancel'])
|
||||
])
|
||||
]) if request.env['purchase.order'].check_access_rights('read', raise_exception=False) else 0
|
||||
return values
|
||||
|
||||
def _purchase_order_get_page_view_values(self, order, access_token, **kwargs):
|
||||
|
||||
@@ -24,12 +24,12 @@ class CustomerPortal(portal.CustomerPortal):
|
||||
values['quotation_count'] = SaleOrder.search_count([
|
||||
('message_partner_ids', 'child_of', [partner.commercial_partner_id.id]),
|
||||
('state', 'in', ['sent', 'cancel'])
|
||||
])
|
||||
]) if SaleOrder.check_access_rights('read', raise_exception=False) else 0
|
||||
if 'order_count' in counters:
|
||||
values['order_count'] = SaleOrder.search_count([
|
||||
('message_partner_ids', 'child_of', [partner.commercial_partner_id.id]),
|
||||
('state', 'in', ['sale', 'done'])
|
||||
])
|
||||
]) if SaleOrder.check_access_rights('read', raise_exception=False) else 0
|
||||
|
||||
return values
|
||||
|
||||
|
||||
Reference in New Issue
Block a user