[WIP] refactoring default_ pricelist and restriction

This commit is contained in:
Pablo
2019-09-09 15:55:12 +02:00
parent 2fc5a5ad05
commit f68528b929
12 changed files with 24 additions and 56 deletions

View File

@@ -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})

View File

@@ -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([

View File

@@ -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: