| 
						
						
							
								
							
						
						
					 | 
					@ -650,89 +650,94 @@ class RoomBooking(models.Model): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    def get_details(self): | 
					 | 
					 | 
					    def get_details(self): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        """ Returns different counts for displaying in dashboard""" | 
					 | 
					 | 
					        """ Returns different counts for displaying in dashboard""" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        today = datetime.today() | 
					 | 
					 | 
					        today = datetime.today() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        tz_name = self.env.user.tz | 
					 | 
					 | 
					        tz_name = False | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if self.env.user.tz: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            tz_name = self.env.user.tz | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        today_utc = pytz.timezone('UTC').localize(today, | 
					 | 
					 | 
					        today_utc = pytz.timezone('UTC').localize(today, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                                  is_dst=False) | 
					 | 
					 | 
					                                                  is_dst=False) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        context_today = today_utc.astimezone(pytz.timezone(tz_name)) | 
					 | 
					 | 
					        if tz_name: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        total_room = self.env['hotel.room'].search_count([]) | 
					 | 
					 | 
					            context_today = today_utc.astimezone(pytz.timezone(tz_name)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        check_in = self.env['room.booking'].search_count( | 
					 | 
					 | 
					            total_room = self.env['hotel.room'].search_count([]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            [('state', '=', 'check_in')]) | 
					 | 
					 | 
					            check_in = self.env['room.booking'].search_count( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        available_room = self.env['hotel.room'].search( | 
					 | 
					 | 
					                [('state', '=', 'check_in')]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            [('status', '=', 'available')]) | 
					 | 
					 | 
					            available_room = self.env['hotel.room'].search( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        reservation = self.env['room.booking'].search_count( | 
					 | 
					 | 
					                [('status', '=', 'available')]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            [('state', '=', 'reserved')]) | 
					 | 
					 | 
					            reservation = self.env['room.booking'].search_count( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        check_outs = self.env['room.booking'].search([]) | 
					 | 
					 | 
					                [('state', '=', 'reserved')]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        check_out = 0 | 
					 | 
					 | 
					            check_outs = self.env['room.booking'].search([]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        staff = 0 | 
					 | 
					 | 
					            check_out = 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        for rec in check_outs: | 
					 | 
					 | 
					            staff = 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            for room in rec.room_line_ids: | 
					 | 
					 | 
					            for rec in check_outs: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                if room.checkout_date.date() == context_today.date(): | 
					 | 
					 | 
					                for room in rec.room_line_ids: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    check_out += 1 | 
					 | 
					 | 
					                    if room.checkout_date.date() == context_today.date(): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            """staff""" | 
					 | 
					 | 
					                        check_out += 1 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            staff = self.env['res.users'].search_count( | 
					 | 
					 | 
					                """staff""" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                [('groups_id', 'in', | 
					 | 
					 | 
					                staff = self.env['res.users'].search_count( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  [self.env.ref('hotel_management_odoo.hotel_group_admin').id, | 
					 | 
					 | 
					                    [('groups_id', 'in', | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                   self.env.ref( | 
					 | 
					 | 
					                      [self.env.ref('hotel_management_odoo.hotel_group_admin').id, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                       'hotel_management_odoo.cleaning_team_group_head').id, | 
					 | 
					 | 
					                       self.env.ref( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                   self.env.ref( | 
					 | 
					 | 
					                           'hotel_management_odoo.cleaning_team_group_head').id, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                       'hotel_management_odoo.cleaning_team_group_user').id, | 
					 | 
					 | 
					                       self.env.ref( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                   self.env.ref( | 
					 | 
					 | 
					                           'hotel_management_odoo.cleaning_team_group_user').id, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                       'hotel_management_odoo.hotel_group_reception').id, | 
					 | 
					 | 
					                       self.env.ref( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                   self.env.ref( | 
					 | 
					 | 
					                           'hotel_management_odoo.hotel_group_reception').id, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                       'hotel_management_odoo.maintenance_team_group_leader').id, | 
					 | 
					 | 
					                       self.env.ref( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                   self.env.ref( | 
					 | 
					 | 
					                           'hotel_management_odoo.maintenance_team_group_leader').id, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                       'hotel_management_odoo.maintenance_team_group_user').id | 
					 | 
					 | 
					                       self.env.ref( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                   ])]) | 
					 | 
					 | 
					                           'hotel_management_odoo.maintenance_team_group_user').id | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        total_vehicle = self.env['fleet.vehicle.model'].search_count([]) | 
					 | 
					 | 
					                       ])]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        available_vehicle = total_vehicle - self.env[ | 
					 | 
					 | 
					            total_vehicle = self.env['fleet.vehicle.model'].search_count([]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'fleet.booking.line'].search_count( | 
					 | 
					 | 
					            available_vehicle = total_vehicle - self.env[ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            [('state', '=', 'check_in')]) | 
					 | 
					 | 
					                'fleet.booking.line'].search_count( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        total_event = self.env['event.event'].search_count([]) | 
					 | 
					 | 
					                [('state', '=', 'check_in')]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        pending_event = self.env['event.event'].search([]) | 
					 | 
					 | 
					            total_event = self.env['event.event'].search_count([]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        pending_events = 0 | 
					 | 
					 | 
					            pending_event = self.env['event.event'].search([]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        today_events = 0 | 
					 | 
					 | 
					            pending_events = 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        for pending in pending_event: | 
					 | 
					 | 
					            today_events = 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if pending.date_end >= fields.datetime.now(): | 
					 | 
					 | 
					            for pending in pending_event: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                pending_events += 1 | 
					 | 
					 | 
					                if pending.date_end >= fields.datetime.now(): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if pending.date_end.date() == fields.date.today(): | 
					 | 
					 | 
					                    pending_events += 1 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                today_events += 1 | 
					 | 
					 | 
					                if pending.date_end.date() == fields.date.today(): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        food_items = self.env['lunch.product'].search_count([]) | 
					 | 
					 | 
					                    today_events += 1 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        food_order = len(self.env['food.booking.line'].search([]).filtered( | 
					 | 
					 | 
					            food_items = self.env['lunch.product'].search_count([]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            lambda r: r.booking_id.state not in ['check_out', 'cancel', | 
					 | 
					 | 
					            food_order = len(self.env['food.booking.line'].search([]).filtered( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                                                 'done'])) | 
					 | 
					 | 
					                lambda r: r.booking_id.state not in ['check_out', 'cancel', | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        """total Revenue""" | 
					 | 
					 | 
					                                                     'done'])) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        total_revenue = 0 | 
					 | 
					 | 
					            """total Revenue""" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        today_revenue = 0 | 
					 | 
					 | 
					            total_revenue = 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        pending_payment = 0 | 
					 | 
					 | 
					            today_revenue = 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        for rec in self.env['account.move'].search( | 
					 | 
					 | 
					            pending_payment = 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                [('payment_state', '=', 'paid')]): | 
					 | 
					 | 
					            for rec in self.env['account.move'].search( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if rec.ref: | 
					 | 
					 | 
					                    [('payment_state', '=', 'paid')]): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                if 'BOOKING' in rec.ref: | 
					 | 
					 | 
					                if rec.ref: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    total_revenue += rec.amount_total | 
					 | 
					 | 
					                    if 'BOOKING' in rec.ref: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    if rec.date == fields.date.today(): | 
					 | 
					 | 
					                        total_revenue += rec.amount_total | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                        today_revenue += rec.amount_total | 
					 | 
					 | 
					                        if rec.date == fields.date.today(): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        for rec in self.env['account.move'].search( | 
					 | 
					 | 
					                            today_revenue += rec.amount_total | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                [('payment_state', '=', 'not_paid')]): | 
					 | 
					 | 
					            for rec in self.env['account.move'].search( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if rec.ref: | 
					 | 
					 | 
					                    [('payment_state', '=', 'not_paid')]): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                if 'BOOKING' in rec.ref: | 
					 | 
					 | 
					                if rec.ref: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    pending_payment += rec.amount_total | 
					 | 
					 | 
					                    if 'BOOKING' in rec.ref: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        return { | 
					 | 
					 | 
					                        pending_payment += rec.amount_total | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'total_room': total_room, | 
					 | 
					 | 
					            return { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'available_room': len(available_room), | 
					 | 
					 | 
					                'total_room': total_room, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'staff': staff, | 
					 | 
					 | 
					                'available_room': len(available_room), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'check_in': check_in, | 
					 | 
					 | 
					                'staff': staff, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'reservation': reservation, | 
					 | 
					 | 
					                'check_in': check_in, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'check_out': check_out, | 
					 | 
					 | 
					                'reservation': reservation, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'total_vehicle': total_vehicle, | 
					 | 
					 | 
					                'check_out': check_out, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'available_vehicle': available_vehicle, | 
					 | 
					 | 
					                'total_vehicle': total_vehicle, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'total_event': total_event, | 
					 | 
					 | 
					                'available_vehicle': available_vehicle, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'today_events': today_events, | 
					 | 
					 | 
					                'total_event': total_event, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'pending_events': pending_events, | 
					 | 
					 | 
					                'today_events': today_events, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'food_items': food_items, | 
					 | 
					 | 
					                'pending_events': pending_events, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'food_order': food_order, | 
					 | 
					 | 
					                'food_items': food_items, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'total_revenue': round(total_revenue, 2), | 
					 | 
					 | 
					                'food_order': food_order, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'today_revenue': round(today_revenue, 2), | 
					 | 
					 | 
					                'total_revenue': round(total_revenue, 2), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'pending_payment': round(pending_payment, 2), | 
					 | 
					 | 
					                'today_revenue': round(today_revenue, 2), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'currency_symbol': self.env.user.company_id.currency_id.symbol, | 
					 | 
					 | 
					                'pending_payment': round(pending_payment, 2), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            'currency_position': self.env.user.company_id.currency_id.position | 
					 | 
					 | 
					                'currency_symbol': self.env.user.company_id.currency_id.symbol, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        } | 
					 | 
					 | 
					                'currency_position': self.env.user.company_id.currency_id.position | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            raise ValidationError(_("Please Enter time zone in user settings.")) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					
  |