Activités : inscription par créneau interne #41

Open
youssef wants to merge 15 commits from youssef/GOLEM:activites_inscription_par_creneau_interne into master
Showing only changes of commit 482acded87 - Show all commits

View File

@ -30,11 +30,16 @@ class GolemActivityRegistration(models.Model):
""" Create registration slot """
reg = super(GolemActivityRegistration, self).create(vals)
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({
'activity_id': reg.activity_id.id,
'member_id': reg.member_id.id,
'hour_start': slots[-1].hour_stop,
'hour_stop': slots[-1].hour_stop + reg.activity_id.slots_duration
'hour_start': hour_start,
'hour_stop': hour_start + reg.activity_id.slots_duration
})
return reg