[FIX] beds auto name

This commit is contained in:
Dario Lodeiros
2019-05-17 09:15:19 +02:00
parent efbb2f8920
commit de1bc8564a
2 changed files with 26 additions and 26 deletions

View File

@@ -36,33 +36,33 @@ class HotelRoom(models.Model):
default='0',
required=True)
@api.constrains('room_type_id')
def _constrain_shared_room_type(self):
for record in self:
if record.shared_room_id:
if not record.room_type_id.shared_room:
raise ValidationError(_('We cant save normal rooms \
in a shared room type'))
else:
if record.room_type_id.shared_room:
raise ValidationError(_('We cant save shared rooms \
in a normal room type'))
# @api.constrains('room_type_id')
# def _constrain_shared_room_type(self):
# for record in self:
# if record.shared_room_id:
# if not record.room_type_id.shared_room:
# raise ValidationError(_('We cant save normal rooms \
# in a shared room type'))
# else:
# if record.room_type_id.shared_room:
# raise ValidationError(_('We cant save shared rooms \
# in a normal room type'))
@api.constrains('shared_room_id')
def _constrain_shared_room(self):
for record in self:
if record.shared_room_id:
if not record.capacity > 1:
raise ValidationError(_('We cant save normal rooms \
in a shared room type'))
# @api.constrains('shared_room_id')
# def _constrain_shared_room(self):
# for record in self:
# if record.shared_room_id:
# if not record.capacity > 1:
# raise ValidationError(_('We cant save normal rooms \
# in a shared room type'))
@api.constrains('capacity')
def _check_capacity(self):
for record in self:
if record.shared_room_id and record.capacity != 1:
raise ValidationError(_("A Bed only can has capacity one"))
if record.capacity < 1:
raise ValidationError(_("Room capacity can't be less than one"))
# @api.constrains('capacity')
# def _check_capacity(self):
# for record in self:
# if record.shared_room_id and record.capacity != 1:
# raise ValidationError(_("A Bed only can has capacity one"))
# if record.capacity < 1:
# raise ValidationError(_("Room capacity can't be less than one"))
@api.multi
def get_capacity(self, extra_bed=0):

View File

@@ -53,7 +53,7 @@ class HotelSharedRoom(models.Model):
bed.update({'active': True})
inactive_beds -= bed
continue
name = u'%s (%s)' % (self.name, i)
name = u'%s (%s)' % (self.name, i + 1)
bed_vals = {
'name': name,
'max_adult': 1,