diff --git a/golem_activity_queue/models/golem_activity.py b/golem_activity_queue/models/golem_activity.py
index 2813940..7ef61f2 100644
--- a/golem_activity_queue/models/golem_activity.py
+++ b/golem_activity_queue/models/golem_activity.py
@@ -33,9 +33,15 @@ class GolemActivity(models.Model):
automated_registration_from_queue = fields.Boolean(default=True)
#ajout d'un champs pour calculer le nombre d'inscription en file d'attente
queue_activity_number = fields.Integer(compute="_queue_activity_number",
- store=True , string='Pending registration number')
+ store=True, string='Pending registration number')
+ #Ajouter/supprimer une file à l'activité et afficher popup pour traitement automatisé
+ @api.multi
+ def queue_allowed_toggle(self):
+ for activity in self:
+ activity.queue_allowed = not activity.queue_allowed
+
#contraint sur nombre d'inscription : une desincription declanche une inscription depuis attente
@api.multi
@api.constrains('activity_registration_ids')
diff --git a/golem_activity_queue/models/golem_activity_queue.py b/golem_activity_queue/models/golem_activity_queue.py
index 654306f..bdadb04 100644
--- a/golem_activity_queue/models/golem_activity_queue.py
+++ b/golem_activity_queue/models/golem_activity_queue.py
@@ -19,10 +19,12 @@
""" GOLEM activities related models """
from odoo import models, fields, api, _
+from odoo.exceptions import ValidationError
class GolemActivityQueue(models.Model):
""" GOLEM Activity Queue """
_name = 'golem.activity.queue'
+ _order = "sequence"
_description = 'GOLEM Activity Queue'
activity_id = fields.Many2one('golem.activity', required=True,
@@ -48,3 +50,16 @@ class GolemActivityQueue(models.Model):
record.is_activity_full = "Full activity"
else:
record.is_activity_full = "Not full activity"
+ @api.constrains('member_id')
+ def _check_member_registration(self):
+ """ Forbid registration in queue when member is already registred in the
+ activity """
+ for queue in self:
+ domain = [('member_id', '=', queue.member_id.id),
+ ('activity_id', '=', queue.activity_id.id)]
+ #verifier si un enrigistrement avec le meme membre et activité est déja fait
+ registrations = self.env['golem.activity.registration'].search(domain)
+ #si oui lancer un erreur
+ if len(registrations):
+ raise ValidationError(_('The member your trying to add to the queue'
+ ' is already registred for this activity'))
diff --git a/golem_activity_queue/models/golem_member.py b/golem_activity_queue/models/golem_member.py
index 15c41ae..5902b48 100644
--- a/golem_activity_queue/models/golem_member.py
+++ b/golem_activity_queue/models/golem_member.py
@@ -24,7 +24,7 @@ class GolemMember(models.Model):
#ajout d'un champs O2M vers member_id de golem.activity.queue
activity_queue_ids = fields.One2many('golem.activity.queue',
- 'member_id','Pending registration')
+ 'member_id', 'Pending registration')
#verifier si nombre d'inscription sur activité est supérieur au place disponible
@api.multi
@@ -34,7 +34,7 @@ class GolemMember(models.Model):
member_id = self[0]
for registration in member_id.activity_registration_ids:
- activity = reservation.activity_id
+ activity = registration.activity_id
if len(activity.activity_registration_ids) > activity.places and activity.queue_allowed:
warning_message = _('This activity : {} is already full, please'
' discard changes and register in'
diff --git a/golem_activity_queue/views/golem_activity_queue_views.xml b/golem_activity_queue/views/golem_activity_queue_views.xml
index 9e53afb..44564c7 100644
--- a/golem_activity_queue/views/golem_activity_queue_views.xml
+++ b/golem_activity_queue/views/golem_activity_queue_views.xml
@@ -67,7 +67,7 @@ along with this program. If not, see .
-
+
diff --git a/golem_activity_queue/views/golem_activity_views.xml b/golem_activity_queue/views/golem_activity_views.xml
index 1f53815..8dcd8e5 100644
--- a/golem_activity_queue/views/golem_activity_views.xml
+++ b/golem_activity_queue/views/golem_activity_views.xml
@@ -40,7 +40,7 @@ along with this program. If not, see .
-
+
@@ -61,7 +61,16 @@ along with this program. If not, see .
string="Register from Queue" type="object"/>
-
+
+
+
+
+
+