Skip to content

Commit

Permalink
[IMP] resource_booking: get_intervals
Browse files Browse the repository at this point in the history
Now we can get intervals of an empty booking,
by specifying the needed values, including the booking type.
  • Loading branch information
norlinhenrik committed Jul 31, 2024
1 parent 26ee154 commit f79b7c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions resource_booking/models/resource_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def _get_available_slots(self, start_dt, end_dt):
test_start += slot_duration
return result

def _get_intervals(self, start_dt, end_dt, combination=None):
def _get_intervals(self, start_dt, end_dt, combination=None, type=None):
"""Get available intervals for this booking,
based on the calendar of the booking type
and the calendar(s) of the relevant resource combination(s)."""
Expand All @@ -638,8 +638,10 @@ def _get_intervals(self, start_dt, end_dt, combination=None):
analyzing_booking=booking_id, exclude_public_holidays=True
)
# RBT calendar uses no resources to restrict bookings
if booking.type_id:
result = booking.type_id.resource_calendar_id._work_intervals_batch(
if not type:
type = booking.type_id
if type and len(type) == 1:
result = type.resource_calendar_id._work_intervals_batch(
start_dt, end_dt
)[False]
else:
Expand Down
2 changes: 1 addition & 1 deletion resource_booking/models/resource_booking_combination.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _get_intervals(self, start_dt, end_dt):
if not combination_intervals:
break # Can't restrict more
calendar = combination.forced_calendar_id or res.calendar_id
# combination_intervals &= calendar._work_intervals(start_dt, end_dt, res)
# Get available intervals (see resource_calendar.py)
combination_intervals &= calendar._work_intervals_batch(
start_dt, end_dt, res
)[res.id]
Expand Down

0 comments on commit f79b7c2

Please sign in to comment.