From a38bdad5a9e078b5ceedaff4f8f855980450df1b Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 12 Mar 2019 12:33:21 +0100 Subject: [PATCH] [UPD] remove default quota constraint --- .../models/hotel_room_type/common.py | 10 ---------- .../models/inherited_hotel_room.py | 12 ++++-------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/hotel_channel_connector/models/hotel_room_type/common.py b/hotel_channel_connector/models/hotel_room_type/common.py index 883cb41f7..629988c64 100644 --- a/hotel_channel_connector/models/hotel_room_type/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -52,16 +52,6 @@ class ChannelHotelRoomType(models.Model): max_price = fields.Float('Max. Price', default=200.0, digits=dp.get_precision('Product Price'), help="Setup the max price to prevent incidents while editing your prices.") - @api.constrains('default_max_avail', 'default_quota') - def _check_availability(self): - for record in self: - if record.default_quota > record.total_rooms_count: - raise ValidationError(_("The quota assigned to the channel manager can't be greater " - "than the total rooms count!")) - if record.default_max_avail > record.total_rooms_count: - raise ValidationError(_("The maximum simultaneous availability can't be greater " - "than the total rooms count!")) - @api.onchange('default_quota', 'default_max_avail') def _onchange_availability(self): for rec in self: diff --git a/hotel_channel_connector/models/inherited_hotel_room.py b/hotel_channel_connector/models/inherited_hotel_room.py index e06527c7e..8ecf7dc03 100644 --- a/hotel_channel_connector/models/inherited_hotel_room.py +++ b/hotel_channel_connector/models/inherited_hotel_room.py @@ -32,9 +32,7 @@ class HotelRoom(models.Model): old_channel_room_type._onchange_availability() channel_availability = self.env['channel.hotel.room.type.availability'].search([ ('room_type_id', '=', item['old_room_type_id']), - '|', - ('quota', '>', old_channel_room_type.total_rooms_count), - ('max_avail', '>', old_channel_room_type.total_rooms_count), + ('channel_avail', '>', old_channel_room_type.total_rooms_count) ], order='date asc') or False if channel_availability: date_range = channel_availability.mapped('date') @@ -44,7 +42,7 @@ class HotelRoom(models.Model): self.env['channel.hotel.room.type.availability'].refresh_availability( checkin=dfrom, checkout=dto, - backend_id=1, + backend_id=old_channel_room_type.backend_id.id, room_type_id=item['old_room_type_id'],) new_channel_room_type = self.env['channel.hotel.room.type'].search([ @@ -53,9 +51,7 @@ class HotelRoom(models.Model): new_channel_room_type._onchange_availability() channel_availability = self.env['channel.hotel.room.type.availability'].search([ ('room_type_id', '=', item['new_room_type_id']), - '|', - ('quota', '>', new_channel_room_type.total_rooms_count), - ('max_avail', '>', new_channel_room_type.total_rooms_count), + ('channel_avail', '>', new_channel_room_type.total_rooms_count) ], order='date asc') or False if channel_availability: date_range = channel_availability.mapped('date') @@ -65,7 +61,7 @@ class HotelRoom(models.Model): self.env['channel.hotel.room.type.availability'].refresh_availability( checkin=dfrom, checkout=dto, - backend_id=1, + backend_id=new_channel_room_type.backend_id.id, room_type_id=item['new_room_type_id'], ) else: res = super().write(vals)