Create registration slot
This commit is contained in:
parent
6916f60f3a
commit
482acded87
@ -30,11 +30,16 @@ class GolemActivityRegistration(models.Model):
|
|||||||
""" Create registration slot """
|
""" Create registration slot """
|
||||||
reg = super(GolemActivityRegistration, self).create(vals)
|
reg = super(GolemActivityRegistration, self).create(vals)
|
||||||
if reg.activity_id.individual_slots:
|
if reg.activity_id.individual_slots:
|
||||||
slots = self.env['golem.activity.registration.slot'].search([], order='hour_stop')
|
slots = self.env['golem.activity.registration.slot'].search(
|
||||||
|
[('activity_id', '=', reg.activity_id.id)], order='hour_stop')
|
||||||
|
if len(slots) >= reg.activity_id.slots_number:
|
||||||
|
verr = _(u'No available slot to register in this activity')
|
||||||
|
raise ValidationError(verr)
|
||||||
|
hour_start = slots[-1].hour_stop if slots else reg.activity_id.hour_start
|
||||||
self.env['golem.activity.registration.slot'].create({
|
self.env['golem.activity.registration.slot'].create({
|
||||||
'activity_id': reg.activity_id.id,
|
'activity_id': reg.activity_id.id,
|
||||||
'member_id': reg.member_id.id,
|
'member_id': reg.member_id.id,
|
||||||
'hour_start': slots[-1].hour_stop,
|
'hour_start': hour_start,
|
||||||
'hour_stop': slots[-1].hour_stop + reg.activity_id.slots_duration
|
'hour_stop': hour_start + reg.activity_id.slots_duration
|
||||||
})
|
})
|
||||||
return reg
|
return reg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user