Skip to content

Commit

Permalink
[IMP]pms: compute overbooking reservation_line
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Apr 17, 2024
1 parent 2e3ae4a commit 4a4850e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pms/models/pms_reservation_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,22 @@ def _compute_price_day_total(self):
discount = first_discount + cancel_discount
line.price_day_total = line.price - discount

@api.depends("room_id")
@api.depends("room_id", "avail_id", "avail_id.real_avail", "occupies_availability")
def _compute_overbooking(self):
for record in self.filtered("room_id"):
if record.occupies_availability and not record.overbooking:
if record.occupies_availability:
record_id = (
record.id
if isinstance(record, int)
else record._origin.id
if hasattr(record, "_origin")
else False
)
if self.env["pms.reservation.line"].search(
[
("date", "=", record.date),
("room_id", "=", record.room_id.id),
("id", "!=", record.id),
("id", "!=", record_id),
("occupies_availability", "=", True),
]
):
Expand Down

0 comments on commit 4a4850e

Please sign in to comment.