Skip to content

Commit

Permalink
[FIX] resource_booking: Don't fail on archived resource
Browse files Browse the repository at this point in the history
Steps to reproduce the problem:

- Create an employee.
- Create a resource booking combination with such employee.
- Create or modify a resource booking type including the previous combination.
- Create a resource booking using that type and combination, and
  schedule it.
- Archive the employee.
- Do any change on the resource booking type.

Current behavior:

Error saying:
"Cannot schedule these bookings because no resources are selected for them:..."

Expected behavior:
No error

The problem is that we do the checks without taking into account the
archived resource, and thus, it fails. Using active_test=False makes
them to appear for the check.
  • Loading branch information
pedrobaeza committed Sep 29, 2023
1 parent 85607fe commit cfcdd9d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion resource_booking/models/resource_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ def _check_scheduling(self):
if not has_meeting:
return
# Ensure all scheduled bookings have booked some resources
has_rbc = self.filtered("combination_id.resource_ids")
has_rbc = self.with_context(active_test=False).filtered(
"combination_id.resource_ids"
)
missing_rbc = has_meeting - has_rbc
if missing_rbc:
raise ValidationError(
Expand Down

0 comments on commit cfcdd9d

Please sign in to comment.