[FIX] constrain shared room type

This commit is contained in:
Dario Lodeiros
2019-05-20 16:58:31 +02:00
parent ec9b803a25
commit 4eb9d023cb

View File

@@ -109,17 +109,17 @@ class HotelRoomType(models.Model):
}) })
return super().create(vals) return super().create(vals)
@api.constrains('shared_room', 'room_ids') # @api.constrains('shared_room', 'room_ids')
def _constrain_shared_room(self): # def _constrain_shared_room(self):
for record in self: # for record in self:
if record.shared_room: # if record.shared_room:
if any(not room.shared_room_id for room in record.room_ids): # if any(not room.shared_room_id for room in record.room_ids):
raise ValidationError(_('We cant save normal rooms \ # raise ValidationError(_('We cant save normal rooms \
in a shared room type')) # in a shared room type'))
else: # else:
if any(room.shared_room_id for room in record.room_ids): # if any(room.shared_room_id for room in record.room_ids):
raise ValidationError(_('We cant save shared rooms \ # raise ValidationError(_('We cant save shared rooms \
in a normal room type')) # in a normal room type'))
@api.multi @api.multi
def unlink(self): def unlink(self):