From d61c5cf67050d32cae1897e217b693ec984196b9 Mon Sep 17 00:00:00 2001 From: AjmalCybro Date: Wed, 31 Jul 2024 17:16:01 +0530 Subject: [PATCH] Jul 31 [UPDT] Updated 'hotel_management_odoo' --- hotel_management_odoo/__manifest__.py | 2 +- hotel_management_odoo/models/room_booking.py | 8 ++++-- .../models/room_booking_line.py | 28 ++++++++++++++++++- .../views/room_booking_views.xml | 1 - 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/hotel_management_odoo/__manifest__.py b/hotel_management_odoo/__manifest__.py index 399f32666..c1367803f 100644 --- a/hotel_management_odoo/__manifest__.py +++ b/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, diff --git a/hotel_management_odoo/models/room_booking.py b/hotel_management_odoo/models/room_booking.py index 30e02e998..250dad363 100644 --- a/hotel_management_odoo/models/room_booking.py +++ b/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), diff --git a/hotel_management_odoo/models/room_booking_line.py b/hotel_management_odoo/models/room_booking_line.py index f06fdaab8..306d5ec63 100644 --- a/hotel_management_odoo/models/room_booking_line.py +++ b/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") diff --git a/hotel_management_odoo/views/room_booking_views.xml b/hotel_management_odoo/views/room_booking_views.xml index a14f74291..9658c955e 100644 --- a/hotel_management_odoo/views/room_booking_views.xml +++ b/hotel_management_odoo/views/room_booking_views.xml @@ -90,7 +90,6 @@