Browse Source

Dec 12: [FIX] Bug Fixed 'hotel_management_odoo'

pull/361/head
Cybrosys Technologies 5 months ago
parent
commit
8c7a5aa93b
  1. 2
      hotel_management_odoo/__manifest__.py
  2. 6
      hotel_management_odoo/doc/RELEASE_NOTES.md
  3. 2
      hotel_management_odoo/models/room_booking.py
  4. 31
      hotel_management_odoo/models/room_booking_line.py
  5. 1
      hotel_management_odoo/views/room_booking_views.xml

2
hotel_management_odoo/__manifest__.py

@ -21,7 +21,7 @@
###############################################################################
{
'name': 'Hotel Management',
'version': '18.0.1.0.0',
'version': '18.0.1.1.0',
'category': 'Industries',
'summary': """A complete Hotel Management System that cover all areas of
Hotel services""" ,

6
hotel_management_odoo/doc/RELEASE_NOTES.md

@ -4,3 +4,9 @@
#### Version 18.0.1.0.0
#### ADD
- Initial commit for Hotel Management
#### 11.12.2024
#### Version 18.0.1.1.0
#### UPDT
- Fixed the issue Room reservation based on check in and check out date.

2
hotel_management_odoo/models/room_booking.py

@ -735,4 +735,4 @@ class RoomBooking(models.Model):
'pending_payment': round(pending_payment, 2),
'currency_symbol': self.env.user.company_id.currency_id.symbol,
'currency_position': self.env.user.company_id.currency_id.position
}
}

31
hotel_management_odoo/models/room_booking_line.py

@ -45,7 +45,6 @@ class RoomBookingLine(models.Model):
" Otherwise sets to current Date",
required=True)
room_id = fields.Many2one('hotel.room', string="Room",
domain=[('status', '=', 'available')],
help="Indicates the Room",
required=True)
uom_qty = fields.Float(string="Duration",
@ -137,3 +136,33 @@ class RoomBookingLine(models.Model):
'currency_id': self.currency_id,
},
)
@api.onchange('checkin_date', 'checkout_date', 'room_id')
def onchange_checkin_date(self):
"""On change of check-in date, check-out date, or room ID,
this method validates if the selected room is available
for the given dates. It searches for existing bookings
in the 'reserved' or 'check_in' state and checks for date
conflicts. If a conflict is found, a ValidationError is raised."""
records = self.env['room.booking'].search(
[('state', 'in', ['reserved', 'check_in'])])
for rec in records:
rec_room_id = rec.room_line_ids.room_id
rec_checkin_date = rec.room_line_ids.checkin_date
rec_checkout_date = rec.room_line_ids.checkout_date
if rec_room_id and rec_checkin_date and rec_checkout_date:
# Check for conflicts with existing room lines
for line in self:
if line.id != rec.id and line.room_id == rec_room_id:
# Check if the dates overlap
if (rec_checkin_date <= line.checkin_date <= rec_checkout_date or
rec_checkin_date <= line.checkout_date <= rec_checkout_date):
raise ValidationError(
_("Sorry, You cannot create a reservation for "
"this date since it overlaps with another "
"reservation..!!"))
if rec_checkout_date <= line.checkout_date and rec_checkin_date >= line.checkin_date:
raise ValidationError(
"Sorry You cannot create a reservation for this"
"date due to an existing reservation between "
"this date")

1
hotel_management_odoo/views/room_booking_views.xml

@ -91,7 +91,6 @@
<list editable="bottom">
<field name="room_id" string="Room"
required="1"
domain="[('is_room_avail','=',True)]"
options="{'no_open': True, 'no_create': True}"/>
<field name="checkin_date"/>
<field name="booking_line_visible"

Loading…
Cancel
Save