Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] resource_booking: get_intervals #136

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resource_booking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"category": "Appointments",
"website": "https://github.com/OCA/calendar",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["pedrobaeza", "ows-cloud"],
"maintainers": ["pedrobaeza", "norlinhenrik"],
"license": "AGPL-3",
"application": True,
"installable": True,
Expand Down
11 changes: 6 additions & 5 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,10 +638,11 @@ 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(
start_dt, end_dt
)[False]
if not type:
type = booking.type_id
if type and len(type) == 1:
r = type.resource_calendar_id._work_intervals_batch(start_dt, end_dt)[False]
result = r
else:
result = Intervals([])
# Restrict with the chosen combination, or to at least one of the
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
Loading