Hi, For Hotel Management module, I want to add functionality for checking availability of rooms between two dates that is, start date and end date by the given type.
Inside of form view I want to show Start Date and End Date then below that Room Type and after that, available rooms between two dates. Can anyone help me to check and then display the rooms available between two dates?
Here is my code,
class hotel_roomsavail(osv.Model):
_name = "hotel.roomsavail"
_columns = {
'check_in':fields.datetime('Check In Date', required=True),
'check_out': fields.datetime('Check Out Date', required=True),
'name':fields.char('Name', size=64),
#'state': fields.selection([('assigned', 'Assigned'), ('unassigned', 'Unassigned')], 'Room Status'),
'cust_reservation_id': fields.many2one('hotel.reservation', 'Reservation'),
'cat_id': fields.many2one('product.category', 'Room Type', domain="[('isroomtype','=',True)]", change_default=True),
#'pricelist_id':fields.many2one('product.pricelist', 'Price List', required=True, readonly=True, states={'draft':[('readonly', False)]}, help="Pricelist for current reservation. "),
#'room_reserved':fields.many2many('hotel.room', 'hotel_reservation_line_room_rel', 'room1_id', 'hotel_reservation_line_id', domain="[('isroom','=',True),('cat_id','=',cat_id)]"),
'room1_id': fields.many2one('hotel.room', 'Room id'),
#'rooms':fields.many2one('hotel.room', 'room_reservation_line_ids'),
}
The form view will be,
<record model="ir.ui.view" id="view_hotel_roomsavail_form">
<field name="name">hotel.roomsavail.form</field>
<field name="model">hotel.roomsavail</field>
<field name="arch" type="xml">
<form string="Rooms Availability" version="7.0">
<group colspan="4" col="4">
<field name="check_in"/>
<field name="check_out"/>
</group>
<separator string="Room Type"/>
<field name="name" invisible="1" />
<field name="cat_id" on_change="on_change_cat(cat_id, parent.check_in, parent.check_out)" select="1" colspan="4" nolabel="1"/>
<newline/>
<!-- <field name="cat_id"/> -->
<!-- <field name="room_id"/> -->
<!--<separator string="Rooms"/>
<field name="room1_id" colspan="4" string="Room Number" nolabel="1" />
</form> -->
<separator colspan='4' string="Check Room Availability" />
<tree>
<field name="room1_id" colspan="4" string="Rooms"/>
<!-- <field name="check_in"/> -->
<!-- <field name="check_out"/> -->
<!-- <field name="state"/> -->
<!-- <field name="cust_reservation_id" colspan="4" string="Customer Reservation"/> -->
</tree>
</form>
</field>
</record>