[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:
Nicolas Martinelli
2020-10-27 15:36:48 +00:00
parent 77d3c1e8fe
commit 691c14c070
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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):
+2 -2
View File
@@ -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