diff --git a/golem_activity_queue/models/golem_activity.py b/golem_activity_queue/models/golem_activity.py
index 3a5d0da..dbe0ea8 100644
--- a/golem_activity_queue/models/golem_activity.py
+++ b/golem_activity_queue/models/golem_activity.py
@@ -26,18 +26,23 @@ class GolemActivity(models.Model):
#ajout d'un champs O2M vers activity_id de golem.activity.queue
activity_queue_ids = fields.One2many('golem.activity.queue',
'activity_id','Pending registration')
- # un boolen pour determiner si une fille d'attente est autorisé
+ # un booleen pour determiner si une fille d'attente est autorisé
queue_allowed = fields.Boolean(default=True)
+ # un booleen pour automatisé l'inscription sur une activité depuis la file d'attente
+ 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')
+ #calculer le nombre d'inscription sur la file d'attente
@api.multi
+ @api.depends('activity_queue_ids')
def _queue_activity_number(self):
for activity in self:
activity.queue_activity_number = len(activity.activity_queue_ids)
+ #lancer une fenetre pour inscritpion en file d'attente
@api.multi
def queue_register(self):
self.ensure_one()
@@ -55,39 +60,77 @@ class GolemActivity(models.Model):
+ @api.multi
+ def register_from_queue(self):
+ for record in self:
+ #recupérer la liste en file d'attente
+ queues = record.activity_queue_ids
+ #trier la liste selon l'id : récupérer l'ancien element
+ queues_sorted = sorted(queues, key=lambda k: k['id'])
+ #valeures pour creer une inscritpion apartir de la file
+ values = {
+ 'activity_id' : queues_sorted[0].activity_id,
+ 'member_id' : queues_sorted[0].member_id
+ }
+ # creation d'inscription
+ record.activity_registration_ids = [(0, 0,values)]
+ #suppression de l'element de la file d'attente
+ record.activity_queue_ids = [(2, queues_sorted[0].id, 0)]
+
+
+ @api.multi
@api.onchange('activity_registration_ids')
def _checkRemain(self):
- if len(self.activity_registration_ids) > self.places and self.queue_allowed:
- return {
- 'warning' : {
- 'title' : _('Warning'),
- 'message': _('No remaining place, please register in the queue'),
+ for record in self:
+ if len(record.activity_registration_ids) > record.places and record.queue_allowed:
+ message = _('No remaining place for the activity : {}, please'
+ ' discard changes and register in the queue using'
+ ' the button bellow')
+ return {
+ 'warning' : {
+ 'title' : _('Warning'),
+ 'message': message.format(record.name),
+ }
}
- }
+ elif len(record.activity_registration_ids) < record.places and record.queue_allowed and record.queue_activity_number > 0:
- """
- @api.multi
- @api.constrains('places_remain')
- def _check_remaining_places(self):
- #Forbid inscription when there is no more place
- for activity in self:
- if activity.places_remain < 5:
-
- if self.queue_allowed:
- print "__________________________ test ______________________"
- return {
- 'name' : _('Do you want to add your registration to the queue?'),
- 'type' : 'ir.actions.act_window',
- 'res_model' : 'golem.activity.queue',
- 'view_mode': 'form',
- 'view_type': 'form',
- 'target': 'new',
+ # passage de l'element depuis la file d'attente automatiquement
+ if record.automated_registration_from_queue:
+ #traitement qui bloque avec message d'erreur can't adapt activitiy_id to newId
+ """
+ #recupérer la liste en file d'attente
+ queues = record.activity_queue_ids
+ #trier la liste selon l'id : récupérer l'ancien element
+ queues_sorted = sorted(queues, key=lambda k: k['id'])
+ #valeures pour creer une inscritpion apartir de la file
+ values = {
+ 'activity_id' : queues_sorted[0].activity_id,
+ 'member_id' : queues_sorted[0].member_id
}
- print "________________________________test 2 __________________"
- raise models.ValidationError("erreur")
+ # creation d'inscription
+ record.activity_registration_ids = [(0, 0,values)]
+ #suppression de l'element de la file d'attente
+ record.activity_queue_ids = [(2, queues_sorted[0].id, 0)]
+ """
+ warningMessage = _('There is a free place for the activity'
+ ' : {}, you can fill it from the queue'
+ ' using the button bellow')
+ return {
+ 'warning' : {
+ 'title' : _('Warning'),
+ 'message': warningMessage.format(record.name)
+ }
+ }
- else:
- emsg = _('Sorry, there is no more place man !')
- raise models.ValidationError(emsg)
-"""
+ #traitement manuel pour le passage de la file d'attente en inscription : button sur queue
+ else :
+ warningMessage = _('There is a free place for the activity'
+ ' : {}, you can fill it from the queue'
+ ' using the button on queue tab')
+ return {
+ 'warning' : {
+ 'title' : _('Warning'),
+ 'message': warningMessage.format(record.name)
+ }
+ }
diff --git a/golem_activity_queue/models/golem_activity_queue.py b/golem_activity_queue/models/golem_activity_queue.py
index 4b085a2..344de07 100644
--- a/golem_activity_queue/models/golem_activity_queue.py
+++ b/golem_activity_queue/models/golem_activity_queue.py
@@ -25,9 +25,9 @@ class GolemActivityQueue(models.Model):
_name = 'golem.activity.queue'
_description = 'GOLEM Activity Queue'
- activity_id = fields.Many2one('golem.activity', required=True)
+ activity_id = fields.Many2one('golem.activity', required=True, ondelete='cascade')
season_id = fields.Many2one(related='activity_id.season_id')
- member_id = fields.Many2one('golem.member', required=True)
+ member_id = fields.Many2one('golem.member', required=True, ondelete='cascade')
is_current = fields.Boolean('Current season?',
related='activity_id.is_current', store=True)
diff --git a/golem_activity_queue/models/golem_member.py b/golem_activity_queue/models/golem_member.py
index dba1311..c9ce103 100644
--- a/golem_activity_queue/models/golem_member.py
+++ b/golem_activity_queue/models/golem_member.py
@@ -26,9 +26,13 @@ class GolemMember(models.Model):
activity_queue_ids = fields.One2many('golem.activity.queue',
'member_id','Pending registration')
+ @api.multi
@api.onchange('activity_registration_ids')
def _checkRemain(self):
- for reservation in self.activity_registration_ids:
+ self.ensure_one()
+ member_id = self[0]
+
+ for reservation in member_id.activity_registration_ids:
activity = reservation.activity_id
if len(activity.activity_registration_ids) > activity.places and activity.queue_allowed:
warning_message = _('This activity : {} is already full, please'
@@ -43,6 +47,8 @@ class GolemMember(models.Model):
@api.multi
def queue_register(self):
+ print "_________________________________________________"
+ print self
self.ensure_one()
member_id = self[0]
return {
diff --git a/golem_activity_queue/views/golem_activity_queue_views.xml b/golem_activity_queue/views/golem_activity_queue_views.xml
index fe893a1..1f7b420 100644
--- a/golem_activity_queue/views/golem_activity_queue_views.xml
+++ b/golem_activity_queue/views/golem_activity_queue_views.xml
@@ -61,7 +61,7 @@ along with this program. If not, see .
golem.activity.queue
-
+
diff --git a/golem_activity_queue/views/golem_activity_views.xml b/golem_activity_queue/views/golem_activity_views.xml
index e3a84b2..500c1ab 100644
--- a/golem_activity_queue/views/golem_activity_views.xml
+++ b/golem_activity_queue/views/golem_activity_views.xml
@@ -25,15 +25,19 @@ along with this program. If not, see .
golem.activity
-
+
+
+
+
@@ -48,8 +52,13 @@ along with this program. If not, see .
+
+
+
+
diff --git a/golem_activity_queue/wizard/golem_activity_queue_choose.py b/golem_activity_queue/wizard/golem_activity_queue_choose.py
index 382ab30..c604b48 100644
--- a/golem_activity_queue/wizard/golem_activity_queue_choose.py
+++ b/golem_activity_queue/wizard/golem_activity_queue_choose.py
@@ -24,7 +24,8 @@ class GolemActivityQueueChooseWizard(models.TransientModel):
"""GOLEM Resource wizard : rchoose activity queue to register in """
_name = "golem.activity.queue.choose.wizard"
- activity_id = fields.Many2one("golem.activity")
+ activity_id = fields.Many2one("golem.activity",
+ domain=[('places_remain','<',1)])
member_id = fields.Many2one("golem.member")