diff --git a/hotel_management_odoo/__manifest__.py b/hotel_management_odoo/__manifest__.py index afdad24b3..d97ee8460 100644 --- a/hotel_management_odoo/__manifest__.py +++ b/hotel_management_odoo/__manifest__.py @@ -22,7 +22,7 @@ { 'name': 'Hotel Management', - 'version': '15.0.1.0.1', + 'version': '15.0.1.0.2', 'summary': 'Hotel Management Application for odoo 15', 'description': """The module helps you to manage rooms,amenities,services,restaurants. End Users can book rooms and reserve foods from hotel restaurant.""", diff --git a/hotel_management_odoo/doc/RELEASE_NOTES.md b/hotel_management_odoo/doc/RELEASE_NOTES.md index 6f22e386b..f89d7a58d 100644 --- a/hotel_management_odoo/doc/RELEASE_NOTES.md +++ b/hotel_management_odoo/doc/RELEASE_NOTES.md @@ -9,3 +9,8 @@ #### Version 15.0.1.0.1 #### UPDT - room reservation-number of persons validation issue + +#### 31.10.2022 +#### Version 15.0.1.0.2 +#### UPDT +- multiple room checkin & checkout diff --git a/hotel_management_odoo/models/hotel_amenity.py b/hotel_management_odoo/models/hotel_amenity.py index 1180375c3..cf0f8bc7e 100644 --- a/hotel_management_odoo/models/hotel_amenity.py +++ b/hotel_management_odoo/models/hotel_amenity.py @@ -40,6 +40,17 @@ class AmenityTypes(models.Model): rec.unlink() return super(AmenityTypes, self).unlink() + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(AmenityTypes, self).copy(default=default) + class HotelAmenity(models.Model): _name = "hotel.amenity" @@ -66,3 +77,14 @@ class HotelAmenity(models.Model): rec = self.env["product.product"].sudo().browse(self.product_id.id) rec.unlink() return super(HotelAmenity, self).unlink() + + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(HotelAmenity, self).copy(default=default) \ No newline at end of file diff --git a/hotel_management_odoo/models/hotel_meals.py b/hotel_management_odoo/models/hotel_meals.py index 895129638..b8c1d021f 100644 --- a/hotel_management_odoo/models/hotel_meals.py +++ b/hotel_management_odoo/models/hotel_meals.py @@ -48,3 +48,14 @@ class HotelMeals(models.Model): rec = self.env["product.product"].sudo().browse(self.product_id.id) rec.unlink() return super(HotelMeals, self).unlink() + + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(HotelMeals, self).copy(default=default) \ No newline at end of file diff --git a/hotel_management_odoo/models/hotel_restaurant.py b/hotel_management_odoo/models/hotel_restaurant.py index 8e322f275..51e60e275 100644 --- a/hotel_management_odoo/models/hotel_restaurant.py +++ b/hotel_management_odoo/models/hotel_restaurant.py @@ -47,4 +47,13 @@ class MealsTypes(models.Model): rec.unlink() return super(MealsTypes, self).unlink() - + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(MealsTypes, self).copy(default=default) \ No newline at end of file diff --git a/hotel_management_odoo/models/hotel_services.py b/hotel_management_odoo/models/hotel_services.py index aec0bf66f..e05453e19 100644 --- a/hotel_management_odoo/models/hotel_services.py +++ b/hotel_management_odoo/models/hotel_services.py @@ -41,6 +41,17 @@ class ServiceCategories(models.Model): rec.unlink() return super(ServiceCategories, self).unlink() + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(ServiceCategories, self).copy(default=default) + class HotelService(models.Model): _name = "hotel.service" @@ -67,3 +78,14 @@ class HotelService(models.Model): rec = self.env["product.product"].sudo().browse(self.product_id.id) rec.unlink() return super(HotelService, self).unlink() + + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(HotelService, self).copy(default=default) \ No newline at end of file diff --git a/hotel_management_odoo/models/res_settings.py b/hotel_management_odoo/models/res_settings.py index c97bbbff0..034c843a9 100644 --- a/hotel_management_odoo/models/res_settings.py +++ b/hotel_management_odoo/models/res_settings.py @@ -19,7 +19,7 @@ # If not, see . # ############################################################################# -from odoo import fields, models, api +from odoo import fields, models, api, _ class ProductProduct(models.Model): @@ -69,6 +69,17 @@ class Rooms(models.Model): rec.unlink() return super(Rooms, self).unlink() + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(Rooms, self).copy(default=default) + class RoomTypes(models.Model): _name = "room.types" @@ -94,9 +105,33 @@ class RoomTypes(models.Model): rec.unlink() return super(RoomTypes, self).unlink() + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(RoomTypes, self).copy(default=default) + class Floor(models.Model): _name = "hotel.floor" _description = "Floor" name = fields.Char(string="Name", required=True) + + @api.returns('self', lambda value: value.id) + def copy(self, default=None): + """For adding '(copy)' string into name while duplicating a record""" + + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)", self.name) + return super(Floor, self).copy(default=default) + + diff --git a/hotel_management_odoo/models/room_check_in_out.py b/hotel_management_odoo/models/room_check_in_out.py index 50e71498c..d292e192f 100644 --- a/hotel_management_odoo/models/room_check_in_out.py +++ b/hotel_management_odoo/models/room_check_in_out.py @@ -28,16 +28,37 @@ class RoomCheckin(models.Model): name = fields.Char(string='Check-In Reference', required=True, copy=False, readonly=True, default=lambda self: _('New')) - rm_id = fields.Many2one('room.reservation.line', domain="[('reservation_id','=',reservation_id)]", string="Room No",required=True) - reservation_id = fields.Many2one('room.reservation', string='Reservation ',required=True, + rm_ids = fields.Many2many('room.reservation.line', + domain="[('reservation_id','=',reservation_id)]", + string="Room No", + required=True) + reservation_id = fields.Many2one('room.reservation', string='Reservation ', required=True, domain="[('state','=','confirm')]") - state = fields.Selection([('draft', 'Draft'),('done', 'Done')], + state = fields.Selection([('draft', 'Draft'), ('done', 'Done')], default='draft') + @api.onchange('reservation_id') + def _rm_ids(self): + res_line = [] + if self.reservation_id.reservation_line_ids: + for line in self.reservation_id.reservation_line_ids: + if line.room_id.status == 'book': + res_line.append(line.id) + return {'domain': {'rm_ids': [('id', 'in', res_line)]}} + def action_checkin(self): - self.rm_id.room_id.write({'status': 'occupied'}) - self.reservation_id.write({'state': 'occupied'}) - self.state='done' + for rec in self.rm_ids: rec.room_id.write({'status': 'occupied'}) + state = self.reservation_id.reservation_line_ids.mapped('room_id') + rs_flag = True + for rec in state: + if rec.status == 'occupied': + rs_flag = True + else: + rs_flag = False + break + if rs_flag: + self.reservation_id.write({'state': 'occupied'}) + self.state = 'done' @api.model def create(self, vals): @@ -51,26 +72,40 @@ class RoomCheckout(models.Model): _name = "room.checkout" _description = 'Room Checkout' - name = fields.Char(string='Check-Out Reference',required=True, copy=False, readonly=True, + name = fields.Char(string='Check-Out Reference', required=True, copy=False, readonly=True, default=lambda self: _('New')) - rm_id = fields.Many2one('room.reservation.line', domain="[('reservation_id','=',reservation_id)]", string="Room No",required=True) - reservation_id = fields.Many2one('room.reservation', string='Reservation', domain="[('state','=','occupied')]",required=True) + rm_ids = fields.Many2many('room.reservation.line', domain="[('reservation_id','=',reservation_id)]", + string="Room No", + required=True) + reservation_id = fields.Many2one('room.reservation', string='Reservation', domain="[('state','=','occupied')]", + required=True) state = fields.Selection([('draft', 'Draft'), ('done', 'Done')], default='draft') + @api.onchange('reservation_id') + def _rm_ids(self): + res_line = [] + if self.reservation_id.reservation_line_ids: + for line in self.reservation_id.reservation_line_ids: + if line.room_id.status == 'occupied': + res_line.append(line.id) + return {'domain': {'rm_ids': [('id', 'in', res_line)]}} + def action_checkout(self): - self.rm_id.room_id.write({'status': 'available'}) - reserv_line = self.env['room.reservation.line'].sudo().search([('reservation_id', '=', self.reservation_id.id)]) - status = 'available' - for rec in reserv_line: - if rec.room_id.status == 'available': - break + for rec in self.rm_ids: rec.room_id.write({'status': 'available'}) + state = self.reservation_id.reservation_line_ids.mapped('room_id') + rs_flag = True + for rec in state: + if rec.status == 'available': + rs_flag = True else: - status = 'occupied' - if status == 'available': + rs_flag = False + break + if rs_flag: self.reservation_id.write({'state': 'done'}) self.state = 'done' + @api.model def create(self, vals): if vals.get('name', _('New')) == _('New'): diff --git a/hotel_management_odoo/views/room_checkin_in_out.xml b/hotel_management_odoo/views/room_checkin_in_out.xml index f0471e451..d8c84a108 100644 --- a/hotel_management_odoo/views/room_checkin_in_out.xml +++ b/hotel_management_odoo/views/room_checkin_in_out.xml @@ -42,7 +42,7 @@ - + @@ -90,7 +90,7 @@ - +