Skip to content

Commit

Permalink
[REF]pms_api_rest: refactoring of get_alerts_by_day service
Browse files Browse the repository at this point in the history
  • Loading branch information
braisab committed May 6, 2022
1 parent ae20ce1 commit bc24036
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pms_api_rest/services/pms_calendar_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,19 +282,17 @@ def get_alerts_per_day(self, pms_calendar_search_param):
for day in (
date_from + timedelta(d) for d in range((date_to - date_from).days + 1)
):
overbooking = False
lines = self.env["pms.reservation.line"].search(
lines = self.env["pms.reservation.line"].search_count(
[
("date", "=", day),
("pms_property_id", "=", pms_calendar_search_param.pms_property_id),
("overbooking", "=", True),
]
)
if any(line.overbooking for line in lines):
overbooking = True
result.append(
PmsCalendarAlertsPerDay(
date=str(datetime.combine(day, datetime.min.time()).isoformat()),
overbooking=overbooking,
overbooking=True if lines > 0 else False,
)
)
return result

0 comments on commit bc24036

Please sign in to comment.