Browse Source

Jul 31 [UPDT] Updated 'hotel_management_odoo'

pull/331/head
AjmalCybro 1 year ago
parent
commit
d61c5cf670
  1. 2
      hotel_management_odoo/__manifest__.py
  2. 8
      hotel_management_odoo/models/room_booking.py
  3. 28
      hotel_management_odoo/models/room_booking_line.py
  4. 1
      hotel_management_odoo/views/room_booking_views.xml

2
hotel_management_odoo/__manifest__.py

@ -21,7 +21,7 @@
###############################################################################
{
'name': 'Odoo17 Hotel Management',
'version': '17.0.1.1.3',
'version': '17.0.1.1.4',
'category': 'Services',
'summary': """Hotel Management, Odoo Hotel Management, Hotel, Room Booking odoo, Amenities Odoo, Event management, Rooms, Events, Food, Booking, Odoo Hotel, Odoo17, Odoo Apps""",
'description': """The module helps you to manage rooms, amenities,

8
hotel_management_odoo/models/room_booking.py

@ -721,10 +721,12 @@ class RoomBooking(models.Model):
if rec.date == fields.date.today():
today_revenue += rec.amount_total
for rec in self.env['account.move'].search(
[('payment_state', '=', 'not_paid')]):
if rec.ref:
if 'BOOKING' in rec.ref:
[('payment_state', 'in', ['not_paid', 'partial'])]):
if rec.ref and 'BOOKING' in rec.ref:
if rec.payment_state == 'not_paid':
pending_payment += rec.amount_total
elif rec.payment_state == 'partial':
pending_payment += rec.amount_residual
return {
'total_room': total_room,
'available_room': len(available_room),

28
hotel_management_odoo/models/room_booking_line.py

@ -45,7 +45,7 @@ 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",
@ -141,3 +141,29 @@ class RoomBookingLine(models.Model):
quantity=self.uom_qty,
price_subtotal=self.price_subtotal,
)
@api.onchange('checkin_date', 'checkout_date', 'room_id')
def onchange_checkin_date(self):
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

@ -90,7 +90,6 @@
<tree 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