check slot hours consistence

This commit is contained in:
Youssef Elouahby 2018-11-02 11:37:16 +01:00
parent 288dc18056
commit 42cec4f0e1
1 changed files with 10 additions and 0 deletions

View File

@ -33,3 +33,13 @@ class GolemActivityRegistrationSlot(models.Model):
ondelete='cascade', index=True)
hour_start = fields.Float('Start time')
hour_stop = fields.Float('Stop time')
@api.constrains('hour_start', 'hour_stop')
def check_slot_hours(self):
""" Check slot hours consistence """
for slot in self:
if slot.hour_start < slot.activity_id.hour_start or \
slot.hour_stop > slot.activity_id.hour_stop:
verr = _(u'Slot start and stop must be between activity start and'
' activity stop.')
raise ValidationError(verr)