diff --git a/hotel/data/hotel_data.xml b/hotel/data/hotel_data.xml index fc3a3d6d8..a38568b1a 100644 --- a/hotel/data/hotel_data.xml +++ b/hotel/data/hotel_data.xml @@ -9,8 +9,8 @@ My Hotel - - + + diff --git a/hotel/models/hotel_folio.py b/hotel/models/hotel_folio.py index 78504a18a..b0da46ba3 100644 --- a/hotel/models/hotel_folio.py +++ b/hotel/models/hotel_folio.py @@ -463,7 +463,7 @@ class HotelFolio(models.Model): addr = self.partner_id.address_get(['invoice']) pricelist = self.partner_id.property_product_pricelist and \ self.partner_id.property_product_pricelist.id or \ - self.env.user.hotel_id.pricelist_id.id + self.env.user.hotel_id.default_pricelist_id.id values = { 'pricelist_id': pricelist, 'payment_term_id': self.partner_id.property_payment_term_id and self.partner_id.property_payment_term_id.id or False, diff --git a/hotel/models/hotel_property.py b/hotel/models/hotel_property.py index b29021ede..cc9f47e9f 100644 --- a/hotel/models/hotel_property.py +++ b/hotel/models/hotel_property.py @@ -23,13 +23,13 @@ class HotelProperty(models.Model): room_ids = fields.One2many('hotel.room', 'hotel_id', 'Rooms') # TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id - pricelist_id = fields.Many2one('product.pricelist', 'Product Pricelist', - help='The default pricelist used in this hotel.', - required=True) + default_pricelist_id = fields.Many2one('product.pricelist', 'Product Pricelist', + help='The default pricelist used in this hotel.', + required=True) # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id - restriction_id = fields.Many2one('hotel.room.type.restriction', 'Restriction Plan', - help='The default restriction plan used in this hotel.', - required=True) + default_restriction_id = fields.Many2one('hotel.room.type.restriction', 'Restriction Plan', + help='The default restriction plan used in this hotel.', + required=True) # TODO: refactoring 'res.config.settings', 'default_arrival_hour' by the current hotel.property.arrival_hour arrival_hour = fields.Char('Arrival Hour (GMT)', diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 5c15ad1a1..6a512b90b 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -670,7 +670,7 @@ class HotelReservation(models.Model): addr = self.partner_id.address_get(['invoice']) pricelist = self.partner_id.property_product_pricelist and \ self.partner_id.property_product_pricelist.id or \ - self.env.user.hotel_id.pricelist_id.id + self.env.user.hotel_id.default_pricelist_id.id values = { 'pricelist_id': pricelist, 'partner_invoice_id': addr['invoice'], diff --git a/hotel/models/hotel_room_type.py b/hotel/models/hotel_room_type.py index 09ca4ba26..7805a477d 100644 --- a/hotel/models/hotel_room_type.py +++ b/hotel/models/hotel_room_type.py @@ -156,16 +156,10 @@ class HotelRoomType(models.Model): raise ValidationError(_('Date From and days are mandatory')) partner_id = kwargs.get('partner_id', False) partner = self.env['res.partner'].browse(partner_id) - pricelist_id = partner.property_product_pricelist.id if partner else \ - self.env['ir.default'].sudo().get( - 'res.config.settings', - 'default_pricelist_id') pricelist_id = kwargs.get('pricelist_id', partner.property_product_pricelist.id and partner.property_product_pricelist.id or - self.env['ir.default'].sudo().get( - 'res.config.settings', - 'default_pricelist_id')) + self.env.user.hotel_id.default_pricelist_id.id) vals.update({ 'partner_id': partner_id if partner_id else False, 'discount': discount, diff --git a/hotel/models/hotel_room_type_restriction.py b/hotel/models/hotel_room_type_restriction.py index 0eef246fb..f3723d62d 100644 --- a/hotel/models/hotel_room_type_restriction.py +++ b/hotel/models/hotel_room_type_restriction.py @@ -6,33 +6,10 @@ from odoo import models, fields, api class HotelRoomTypeRestriction(models.Model): _name = 'hotel.room.type.restriction' - @api.model - def _get_default_hotel(self): - return self.env.user.hotel_id - name = fields.Char('Restriction Plan Name', required=True) item_ids = fields.One2many('hotel.room.type.restriction.item', 'restriction_id', string='Restriction Items', copy=True) active = fields.Boolean('Active', default=True, help='If unchecked, it will allow you to hide the ' - 'restriction plan without removing it.') - # TODO: Review this relationship. - # 1. How to create a new hotel if hotel_property.restriction_id is required? - # 2. If you delete the hotel_id from the hotel is also deleted - hotel_ids = fields.One2many('hotel.property', - 'restriction_id', string='Hotel', - default=_get_default_hotel, required=True) - - @api.multi - @api.depends('name') - def name_get(self): - # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id - restriction_id = self.env.user.hotel_id.restriction_id.id - names = [] - for record in self: - if record.id == restriction_id: - names.append((record.id, '%s (Default)' % record.name)) - else: - names.append((record.id, record.name)) - return names + 'restriction plan without removing it.') \ No newline at end of file diff --git a/hotel/views/hotel_property_views.xml b/hotel/views/hotel_property_views.xml index 65c1190cd..b7e368d50 100644 --- a/hotel/views/hotel_property_views.xml +++ b/hotel/views/hotel_property_views.xml @@ -21,8 +21,8 @@ - - + + diff --git a/hotel/views/hotel_room_type_restriction_views.xml b/hotel/views/hotel_room_type_restriction_views.xml index 5e2df2a3f..6227988a3 100644 --- a/hotel/views/hotel_room_type_restriction_views.xml +++ b/hotel/views/hotel_room_type_restriction_views.xml @@ -21,9 +21,6 @@ - - -
diff --git a/hotel/wizard/wizard_reservation.py b/hotel/wizard/wizard_reservation.py index a251d808e..60ff30461 100644 --- a/hotel/wizard/wizard_reservation.py +++ b/hotel/wizard/wizard_reservation.py @@ -51,7 +51,7 @@ class FolioWizard(models.TransientModel): @api.model def _get_default_pricelist(self): - return self.env.user.hotel_id.pricelist_id.id + return self.env.user.hotel_id.default_pricelist_id.id partner_id = fields.Many2one('res.partner', required=True, string="Customer") email = fields.Char('E-mail') @@ -106,7 +106,7 @@ class FolioWizard(models.TransientModel): vals = {} pricelist = self.partner_id.property_product_pricelist and \ self.partner_id.property_product_pricelist.id or \ - self.env.user.hotel_id.pricelist_id.id + self.env.user.hotel_id.default_pricelist_id.id vals.update({ 'pricelist_id': pricelist, 'email': self.partner_id.email, diff --git a/hotel_calendar/models/hotel_calendar_management.py b/hotel_calendar/models/hotel_calendar_management.py index e1511bcd0..670fc346d 100644 --- a/hotel_calendar/models/hotel_calendar_management.py +++ b/hotel_calendar/models/hotel_calendar_management.py @@ -218,10 +218,10 @@ class HotelCalendarManagement(models.TransientModel): vals = {} # TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id if not pricelist_id: - pricelist_id = self.env.user.hotel_id.pricelist_id.id + pricelist_id = self.env.user.hotel_id.default_pricelist_id.id # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id if not restriction_id: - restriction_id = self.env.user.hotel_id.restriction_id.id + restriction_id = self.env.user.hotel_id.default_restriction_id.id # TODO: ensure pricelist_id and restriction_id belong to the current hotel vals.update({'pricelist_id': pricelist_id}) diff --git a/hotel_calendar/models/inherited_hotel_reservation.py b/hotel_calendar/models/inherited_hotel_reservation.py index daec4ea38..5265762e9 100644 --- a/hotel_calendar/models/inherited_hotel_reservation.py +++ b/hotel_calendar/models/inherited_hotel_reservation.py @@ -132,7 +132,7 @@ class HotelReservation(models.Model): def _hcalendar_room_data(self, rooms): _logger.warning('_found [%s] rooms for hotel [%s]', len(rooms), self.env.user.hotel_id.id) # TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id - pricelist_id = self.env.user.hotel_id.pricelist_id.id + pricelist_id = self.env.user.hotel_id.default_pricelist_id.id json_rooms = [ { 'id': room.id, @@ -239,7 +239,7 @@ class HotelReservation(models.Model): @api.model def get_hcalendar_pricelist_data(self, dfrom_dt, dto_dt): # TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id - pricelist_id = self.env.user.hotel_id.pricelist_id.id + pricelist_id = self.env.user.hotel_id.default_pricelist_id.id hotel_id = self.env.user.hotel_id.id room_types_ids = self.env['hotel.room.type'].search([ ('hotel_id', '=', hotel_id) @@ -294,10 +294,10 @@ class HotelReservation(models.Model): @api.model def get_hcalendar_restrictions_data(self, dfrom_dt, dto_dt): """ Returns the room type restrictions between dfrom_dt and dto_dt - for the room types of the current_hotel and the its default restriction plan + for the room types of the current_hotel within the default restriction plan """ hotel_id = self.env.user.hotel_id.id - restriction_id = self.env.user.hotel_id.restriction_id.id + restriction_id = self.env.user.hotel_id.default_restriction_id.id json_rooms_rests = {} room_typed_ids = self.env['hotel.room.type'].search([ diff --git a/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py b/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py index f3944310d..b48807638 100644 --- a/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py +++ b/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py @@ -12,7 +12,7 @@ class HotelRoomTypeResrtrictionItem(models.Model): def create(self, vals): res = super(HotelRoomTypeResrtrictionItem, self).create(vals) # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id - if res.restriction_id.id == self.env.user.hotel_id.restriction_id.id: + if res.restriction_id.id == self.env.user.hotel_id.default_restriction_id.id: self.env['bus.hotel.calendar'].send_restriction_notification({ 'restriction_id': res.restriction_id.id, 'date': res.date, @@ -51,7 +51,7 @@ class HotelRoomTypeResrtrictionItem(models.Model): @api.multi def unlink(self): # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id - default_restriction_id = self.env.user.hotel_id.restriction_id.id + default_restriction_id = self.env.user.hotel_id.default_restriction_id.id # Construct dictionary with relevant info of removed records unlink_vals = [] for record in self: