From 504f3013ccfabd7887c5689b4210ed05f72a6cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 29 Jan 2025 11:45:42 +0100 Subject: [PATCH] Disable counting in super search call of ResourceAccessMixin only when enforcing access The search method must always return an integer when count is True. Closes #13846 --- trytond/trytond/ir/resource.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/trytond/trytond/ir/resource.py b/trytond/trytond/ir/resource.py index 0bbdcac87e..3264aa13c0 100644 --- a/trytond/trytond/ir/resource.py +++ b/trytond/trytond/ir/resource.py @@ -73,10 +73,12 @@ class ResourceAccessMixin(ModelStorage): cls, domain, offset=0, limit=None, order=None, count=False, query=False): transaction = Transaction() + enforce_access = ( + not query and transaction.user and transaction.check_access) result = super().search( domain, offset=offset, limit=limit, order=order, - count=False if not query else count, query=query) - if not query and transaction.user and transaction.check_access: + count=False if enforce_access else count, query=query) + if enforce_access: records = result resources = defaultdict(set) allowed = set()