| 
						
						
						
					 | 
				
				 | 
				
					@ -1,6 +1,6 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					from odoo import models, fields, api | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					from odoo.exceptions import UserError, ValidationError,Warning | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					from datetime import date,datetime,timedelta | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					class booking_room(models.Model): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    _name = 'booking.room' | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -10,14 +10,24 @@ class booking_room(models.Model): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    name=fields.Char('room name',compute='_compute_room_name') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    description = fields.Text('description') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    capacity = fields.Integer('max capacity') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    available_seats = fields.Integer('available seats') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    available_seats = fields.Integer('available seats', compute='_compute_available_seats') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    location_id=fields.Many2one('booking.location', string='location') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    def _compute_available_seats(self): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for reg in self: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            today=date.today() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            events=self.env['event.event'].search([('booking_event','=',True),('date_end','>=',today)]) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            count_room_seats=0 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if events: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                for event in events: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    count_room_seats=count_room_seats+self.env['event.registration'].search_count([('room_id','=',int(reg.id))]) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            reg.available_seats=count_room_seats | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    def _compute_room_name(self): | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for rec in self: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             rec.name='' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             if rec.name2: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                rec.name=rec.name2+'('+str(rec.capacity)+')' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                rec.name=rec.name2+'('+str(rec.available_seats)+'/'+str(rec.capacity)+')' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					class booking_room_occupation(models.Model): | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |