From f1b8a9511f7f4134a43a61924c55a2f199c8bd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 17 May 2024 09:56:02 +0200 Subject: [PATCH] [FIX] resource_booking: Add booking_count to portal values only if requested The _prepare_home_portal_values() method sometimes requests booking_count and only then should we return the value. --- resource_booking/controllers/portal.py | 5 +++-- resource_booking/templates/portal.xml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/resource_booking/controllers/portal.py b/resource_booking/controllers/portal.py index b8338cdd..bf518341 100644 --- a/resource_booking/controllers/portal.py +++ b/resource_booking/controllers/portal.py @@ -26,8 +26,9 @@ def _get_booking_sudo(self, booking_id, access_token): def _prepare_home_portal_values(self, counters): """Compute values for multi-booking portal views.""" values = super()._prepare_home_portal_values(counters) - booking_count = request.env["resource.booking"].search_count([]) - values.update({"booking_count": booking_count}) + if "booking_count" in counters: + booking_count = request.env["resource.booking"].search_count([]) + values.update({"booking_count": booking_count}) return values def _booking_get_page_view_values(self, booking_sudo, access_token, **kwargs): diff --git a/resource_booking/templates/portal.xml b/resource_booking/templates/portal.xml index 7c6324d6..116dd64c 100644 --- a/resource_booking/templates/portal.xml +++ b/resource_booking/templates/portal.xml @@ -257,7 +257,7 @@