Skip to content

Commit

Permalink
[FIX] resource_booking: Add booking_count to portal values only if re…
Browse files Browse the repository at this point in the history
…quested

The _prepare_home_portal_values() method sometimes requests booking_count
and only then should we return the value.
  • Loading branch information
victoralmau committed May 17, 2024
1 parent 1a21cda commit f1b8a95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions resource_booking/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion resource_booking/templates/portal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
</xpath>
</template>
<template
id="portal_my_home"
id="portal_my_home_resource_booking"
inherit_id="portal.portal_my_home"
customize_show="True"
>
Expand Down

0 comments on commit f1b8a95

Please sign in to comment.