mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] skip cancelled reservation in availability checks
This commit is contained in:
@@ -741,7 +741,7 @@ class HotelReservation(models.Model):
|
|||||||
def onchange_room_availabiltiy_domain(self):
|
def onchange_room_availabiltiy_domain(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if self.checkin and self.checkout:
|
if self.checkin and self.checkout:
|
||||||
if self.overbooking or self.reselling:
|
if self.overbooking or self.reselling or self.state in ('cancelled'):
|
||||||
return
|
return
|
||||||
occupied = self.env['hotel.reservation'].get_reservations(
|
occupied = self.env['hotel.reservation'].get_reservations(
|
||||||
self.checkin,
|
self.checkin,
|
||||||
@@ -1141,7 +1141,9 @@ class HotelReservation(models.Model):
|
|||||||
if fields.Date.from_string(self.checkin) >= fields.Date.from_string(self.checkout):
|
if fields.Date.from_string(self.checkin) >= fields.Date.from_string(self.checkout):
|
||||||
raise ValidationError(_('Room line Check In Date Should be \
|
raise ValidationError(_('Room line Check In Date Should be \
|
||||||
less than the Check Out Date!'))
|
less than the Check Out Date!'))
|
||||||
if not self.overbooking and not self._context.get("ignore_avail_restrictions", False):
|
if not self.overbooking \
|
||||||
|
and self.state not in ('cancelled') \
|
||||||
|
and not self._context.get("ignore_avail_restrictions", False):
|
||||||
occupied = self.env['hotel.reservation'].get_reservations(
|
occupied = self.env['hotel.reservation'].get_reservations(
|
||||||
self.checkin,
|
self.checkin,
|
||||||
(fields.Date.from_string(self.checkout) - timedelta(days=1)).
|
(fields.Date.from_string(self.checkout) - timedelta(days=1)).
|
||||||
|
|||||||
Reference in New Issue
Block a user