[UPD] Task 973 - constrain for archive

This commit is contained in:
Pablo
2019-07-26 13:08:47 +02:00
parent fca3234cd6
commit 902a284fbf

View File

@@ -137,6 +137,14 @@ class HotelRoomType(models.Model):
for record in self: for record in self:
record.capacity = record.get_capacity() record.capacity = record.get_capacity()
@api.constrains('active')
def _check_active(self):
for record in self:
if not record.active and record.total_rooms_count > 0:
raise ValidationError(
_("You can not archive a room type with active rooms.") + " " +
_("Please, change the %s room(s) to other room type.") % str(record.total_rooms_count))
@api.multi @api.multi
def get_restrictions(self, date, restriction_plan_id): def get_restrictions(self, date, restriction_plan_id):
self.ensure_one() self.ensure_one()