From b158be74fdf5db5394634283a6f64e2d9941b1b0 Mon Sep 17 00:00:00 2001 From: mgite Date: Tue, 19 Nov 2024 13:03:38 +0400 Subject: [PATCH] Status fields --- bross_hms/models/hms_models.py | 15 ++++++--------- bross_hms/views/bookings.xml | 17 ++++++----------- bross_hms/views/room_revenue.xml | 17 ++++++----------- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/bross_hms/models/hms_models.py b/bross_hms/models/hms_models.py index 1944b04..4ae4fea 100644 --- a/bross_hms/models/hms_models.py +++ b/bross_hms/models/hms_models.py @@ -188,42 +188,39 @@ class HmsBookings(models.Model): status = fields.Many2one(comodel_name="hms.status", string="Status", compute="_compute_checkin_checkout_date", store=True) booking_status_text = fields.Char(string="Booking Status ", compute="_compute_checkin_checkout_date", store=True) - show_booking_status = fields.Boolean(string="Show Booking Status", compute="_compute_checkin_checkout_date", store=True) status_text = fields.Char(string="Status ", compute="_compute_checkin_checkout_date", store=True) - show_status = fields.Boolean(string="Show Status", compute="_compute_checkin_checkout_date", store=True) @api.depends('roomStays', 'payment_ids') def _compute_checkin_checkout_date(self): for booking in self: # Status fields - booking.show_booking_status = False - booking.show_status = False if booking.roomStays.filtered(lambda stay: stay.bookingStatus.name == 'Confirmed'): booking.booking_status = self.env['hms.booking.status'].search([('name', '=', 'Confirmed')]).id booking.booking_status_text = f"Confirmed ({len(booking.roomStays.filtered(lambda stay: stay.bookingStatus.name == 'Confirmed'))} / {len(booking.roomStays)})" - booking.show_booking_status = True elif not booking.roomStays.filtered(lambda stay: stay.bookingStatus.name != 'Cancelled'): booking.booking_status = self.env['hms.booking.status'].search([('name', '=', 'Cancelled')]).id + booking.booking_status_text = "Cancelled" elif not booking.roomStays.filtered(lambda stay: stay.bookingStatus.name != 'Pending'): - booking.booking_status = self.env['hms.booking.status'].search([('name', '=', 'UpcoPendingming')]).id - + booking.booking_status = self.env['hms.booking.status'].search([('name', '=', 'Pending')]).id + booking.booking_status_text = "Pending" if not booking.roomStays.filtered(lambda stay: stay.status.name == 'CheckedIn') and not booking.roomStays.filtered(lambda stay: stay.status.name == 'CheckedOut') and booking.roomStays.filtered(lambda stay: stay.status.name == 'New'): booking.status = self.env['hms.status'].search([('name', '=', 'Upcoming')]).id + booking.status_text = "Upcoming" elif booking.roomStays.filtered(lambda stay: stay.status.name == 'CheckedIn'): checked_in_records = self.env['hms.status'].search([('name', '=', 'CheckedIn')]) booking.status = checked_in_records.id booking.status_text = f"CheckedIn ({len(booking.roomStays.filtered(lambda stay: stay.status.name == 'CheckedIn'))} / {len(booking.roomStays)})" - booking.show_status = True elif booking.roomStays.filtered(lambda stay: stay.status.name == 'CheckedOut'): checked_out_records = self.env['hms.status'].search([('name', '=', 'CheckedOut')]) booking.status = checked_out_records.id booking.status_text = f"CheckedOut ({len(booking.roomStays.filtered(lambda stay: stay.status.name == 'CheckedOut'))} / {len(booking.roomStays)})" - booking.show_status = True elif not booking.roomStays.filtered(lambda stay: stay.status.name != 'Cancelled'): booking.status = self.env['hms.status'].search([('name', '=', 'Cancelled')]).id + booking.status_text = "Cancelled" elif not booking.roomStays.filtered(lambda stay: stay.status.name != 'No Show'): booking.status = self.env['hms.status'].search([('name', '=', 'No Show')]).id + booking.status_text = "No Show" # Computed fields checkin_dates = booking.roomStays.mapped('checkInDateTime') diff --git a/bross_hms/views/bookings.xml b/bross_hms/views/bookings.xml index 0740904..229e953 100644 --- a/bross_hms/views/bookings.xml +++ b/bross_hms/views/bookings.xml @@ -16,8 +16,8 @@ - - + + @@ -62,15 +62,10 @@ - - - - - - - - - + + + + diff --git a/bross_hms/views/room_revenue.xml b/bross_hms/views/room_revenue.xml index 08b21c0..933f158 100644 --- a/bross_hms/views/room_revenue.xml +++ b/bross_hms/views/room_revenue.xml @@ -18,8 +18,8 @@ - - + + @@ -65,15 +65,10 @@ - - - - - - - - - + + + +