[UPD] remove default quota constraint

This commit is contained in:
Pablo
2019-03-12 12:33:21 +01:00
committed by Dario Lodeiros
parent 6d85468615
commit a38bdad5a9
2 changed files with 4 additions and 18 deletions

View File

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

View File

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