diff --git a/hotel_channel_connector/models/hotel_reservation/common.py b/hotel_channel_connector/models/hotel_reservation/common.py index 05aa58d47..9378b0653 100644 --- a/hotel_channel_connector/models/hotel_reservation/common.py +++ b/hotel_channel_connector/models/hotel_reservation/common.py @@ -185,6 +185,7 @@ class HotelReservation(models.Model): vals.update({'to_read': True}) reservation_id = super(HotelReservation, self).create(vals) + import wdb; wdb.set_trace() # restar quota si en viene de wubook y es mayor que cero backend_id = self.env['channel.hotel.room.type'].search([ ('odoo_id', '=', vals['room_type_id']) diff --git a/hotel_channel_connector/models/hotel_room_type/common.py b/hotel_channel_connector/models/hotel_room_type/common.py index d30a277d8..e32cd5044 100644 --- a/hotel_channel_connector/models/hotel_room_type/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -41,7 +41,7 @@ class ChannelHotelRoomType(models.Model): default_max_avail = fields.Integer("Max. Availability", default=_default_max_avail, help="Maximum simultaneous availability given no availability rules. " "Use `-1` for using maximum simultaneous availability.") - default_availability = fields.Integer(default=_default_availability, readonly = True, + default_availability = fields.Integer(default=_default_availability, readonly=True, help="Default availability for OTAs. " "The availability is calculated based on the quota, " "the maximum simultaneous availability and " @@ -52,16 +52,16 @@ 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', 'default_availability') + @api.constrains('default_max_avail', 'default_quota') def _check_availability(self): for record in self: - if record.quota > record.room_type_id.total_rooms_count: + 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.max_avail > record.quota) and (record.quota >= 0): - raise ValidationError(_("The maximum simultaneous availability can't be greater " - "than a given quota.")) - if record.max_avail > record.room_type_id.total_rooms_count: + # if (record.default_max_avail > record.default_quota) and (record.default_quota >= 0): + # raise ValidationError(_("The maximum simultaneous availability can't be greater " + # "than a given quota.")) + if record.default_max_avail > record.total_rooms_count: raise ValidationError(_("The maximum simultaneous availability can't be greater " "than the total rooms count!")) @@ -178,6 +178,7 @@ class HotelRoomType(models.Model): 'default_odoo_id': self.id, 'default_name': self.name, 'default_ota_capacity': self.capacity, + 'default_capacity': self.capacity, 'default_list_price': self.list_price, 'default_total_rooms_count': self.total_rooms_count} return action diff --git a/hotel_channel_connector/models/hotel_room_type_availability/common.py b/hotel_channel_connector/models/hotel_room_type_availability/common.py index 9510715c7..e92b94248 100644 --- a/hotel_channel_connector/models/hotel_room_type_availability/common.py +++ b/hotel_channel_connector/models/hotel_room_type_availability/common.py @@ -165,7 +165,8 @@ class ChannelHotelRoomTypeAvailability(models.Model): to_eval.append(room_type_bind.default_availability) else: # default availability for OTAs if not record given - # This should happens only when refreshing availability from hotel.reservation + # This should never happens because the channel.hotel.room.type.availability + # should be created and the quota update (if needed) __before__ refreshing_availability() to_eval.append(room_type_bind.default_availability) avail = max(min(to_eval), 0) @@ -185,7 +186,8 @@ class ChannelHotelRoomTypeAvailability(models.Model): if room_type_avail_id.channel_avail != avail: room_type_avail_id.write({'channel_avail': avail}) else: - # This should happens only when refreshing availability from hotel.reservation + # This should never happens because the channel.hotel.room.type.availability + # should be created and the quota update (if needed) __before__ refreshing_availability() channel_room_type_avail_obj.create({ 'odoo_id': room_type_bind.odoo_id.id, 'backend_id': backend_id, diff --git a/hotel_channel_connector/views/channel_hotel_room_type_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_views.xml index 2f243ec66..6251566c9 100644 --- a/hotel_channel_connector/views/channel_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_views.xml @@ -36,10 +36,10 @@ - +