Amélioration du fonction de basculement automatique depuis membre : utilisation vals
This commit is contained in:
parent
3ab701c8d4
commit
e4596cbda0
@ -26,18 +26,19 @@ class GolemActivity(models.Model):
|
|||||||
|
|
||||||
#ajout d'un champs O2M vers activity_id de golem.activity.queue
|
#ajout d'un champs O2M vers activity_id de golem.activity.queue
|
||||||
activity_queue_ids = fields.One2many('golem.activity.queue',
|
activity_queue_ids = fields.One2many('golem.activity.queue',
|
||||||
'activity_id','Pending registration')
|
'activity_id', 'Pending registration')
|
||||||
# un booleen 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, readonly=True)
|
queue_allowed = fields.Boolean(default=True, readonly=True)
|
||||||
# un booleen pour automatisé l'inscription sur une activité depuis la file d'attente
|
# un booleen pour automatisé l'inscription sur une activité depuis la file d'attente
|
||||||
automated_registration_from_queue = fields.Boolean(default=True, readonly=True)
|
auto_registration_from_queue = fields.Boolean(default=True, readonly=True)
|
||||||
#ajout d'un champs pour calculer le nombre d'inscription en file d'attente
|
#ajout d'un champs pour calculer le nombre d'inscription en file d'attente
|
||||||
queue_activity_number = fields.Integer(compute="_queue_activity_number",
|
queue_activity_number = fields.Integer(compute="_compute_queue_activity_number",
|
||||||
store=True, string='Pending registration number')
|
store=True, string='Pending registration number')
|
||||||
@api.multi
|
@api.multi
|
||||||
def automated_registration_from_queue_toggle(self):
|
def auto_registration_from_queue_toggle(self):
|
||||||
|
""" switch registration from queueu mode """
|
||||||
for activity in self:
|
for activity in self:
|
||||||
activity.automated_registration_from_queue = not activity.automated_registration_from_queue
|
activity.auto_registration_from_queue = not activity.auto_registration_from_queue
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
@ -65,7 +66,7 @@ class GolemActivity(models.Model):
|
|||||||
|
|
||||||
#mettre à jour le status d'activité remplis sur chaque attente
|
#mettre à jour le status d'activité remplis sur chaque attente
|
||||||
@api.constrains('places_remain')
|
@api.constrains('places_remain')
|
||||||
def updateActivityState(self):
|
def update_activity_fullness(self):
|
||||||
"""updates queue.is_activity_full based on places_remain"""
|
"""updates queue.is_activity_full based on places_remain"""
|
||||||
for activity in self:
|
for activity in self:
|
||||||
for queue in self.activity_queue_ids:
|
for queue in self.activity_queue_ids:
|
||||||
@ -87,7 +88,7 @@ class GolemActivity(models.Model):
|
|||||||
activity.activity_queue_ids = [(2, queue.id, 0)]
|
activity.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
#changer l'état de queue allowed et automated_registration en false
|
#changer l'état de queue allowed et automated_registration en false
|
||||||
activity.queue_allowed = False
|
activity.queue_allowed = False
|
||||||
activity.automated_registration_from_queue = False
|
activity.auto_registration_from_queue = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#lancer popup pour choisir activité à s'inscrire
|
#lancer popup pour choisir activité à s'inscrire
|
||||||
@ -105,7 +106,8 @@ class GolemActivity(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#contraint sur nombre d'inscription : une desincription declanche une inscription depuis attente
|
#contraint sur nombre d'inscription : une desincription declanche une inscription
|
||||||
|
#depuis attente mode automatique
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('activity_registration_ids')
|
@api.constrains('activity_registration_ids')
|
||||||
def _automatedRegistrationFromQueue(self):
|
def _automatedRegistrationFromQueue(self):
|
||||||
@ -116,9 +118,9 @@ class GolemActivity(models.Model):
|
|||||||
#3 verifier si la file est activé
|
#3 verifier si la file est activé
|
||||||
#4 verifier si linscription automatique depuis la file est activé
|
#4 verifier si linscription automatique depuis la file est activé
|
||||||
if (len(record.activity_registration_ids) < record.places and
|
if (len(record.activity_registration_ids) < record.places and
|
||||||
record.queue_activity_number > 0 and
|
record.queue_activity_number > 0 and
|
||||||
record.queue_allowed and
|
record.queue_allowed and
|
||||||
record.automated_registration_from_queue):
|
record.auto_registration_from_queue):
|
||||||
#recupérer la liste en file d'attente
|
#recupérer la liste en file d'attente
|
||||||
queues = record.activity_queue_ids
|
queues = record.activity_queue_ids
|
||||||
#trier la liste selon l'id : récupérer l'ancien element
|
#trier la liste selon l'id : récupérer l'ancien element
|
||||||
@ -131,13 +133,15 @@ class GolemActivity(models.Model):
|
|||||||
membre_registred = False
|
membre_registred = False
|
||||||
#recuperer la liste des registration
|
#recuperer la liste des registration
|
||||||
registrations = record.activity_registration_ids
|
registrations = record.activity_registration_ids
|
||||||
#parcourir les registration afin de vérifier si le memebre sur l'attente déja inscrit
|
#parcourir les registration afin de vérifier si le memebre sur l'attente
|
||||||
|
#déja inscrit
|
||||||
for registration in registrations:
|
for registration in registrations:
|
||||||
#compare le membre sur l'attente au membre sur l'inscription
|
#compare le membre sur l'attente au membre sur l'inscription
|
||||||
if queue.member_id == registration.member_id:
|
if queue.member_id == registration.member_id:
|
||||||
#si membre trouvé inscrit sur l'activité on le supprime de la queue
|
#si membre trouvé inscrit sur l'activité on le supprime de la queue
|
||||||
record.activity_queue_ids = [(2, queue.id, 0)]
|
record.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
#si membre trouvé on mentionne enregistré, on passe au registration suivante
|
#si membre trouvé on mentionne enregistré, on passe au
|
||||||
|
#registration suivante
|
||||||
membre_registred = True
|
membre_registred = True
|
||||||
break
|
break
|
||||||
#à la sortie de la boucle si le membre nest pas sur inscription faire une
|
#à la sortie de la boucle si le membre nest pas sur inscription faire une
|
||||||
@ -148,7 +152,7 @@ class GolemActivity(models.Model):
|
|||||||
'member_id' : queue.member_id
|
'member_id' : queue.member_id
|
||||||
}
|
}
|
||||||
# creation d'inscription
|
# creation d'inscription
|
||||||
record.activity_registration_ids = [(0, 0,values)]
|
record.activity_registration_ids = [(0, 0, values)]
|
||||||
#suppression de l'element de la file d'attente
|
#suppression de l'element de la file d'attente
|
||||||
record.activity_queue_ids = [(2, queue.id, 0)]
|
record.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
#sortir de la boucle parcourissante la queue puisque inscription faite
|
#sortir de la boucle parcourissante la queue puisque inscription faite
|
||||||
@ -159,13 +163,15 @@ class GolemActivity(models.Model):
|
|||||||
#calculer le nombre d'inscription sur la file d'attente
|
#calculer le nombre d'inscription sur la file d'attente
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('activity_queue_ids')
|
@api.depends('activity_queue_ids')
|
||||||
def _queue_activity_number(self):
|
def _compute_queue_activity_number(self):
|
||||||
|
""" compute number of queue registration for activity"""
|
||||||
for activity in self:
|
for activity in self:
|
||||||
activity.queue_activity_number = len(activity.activity_queue_ids)
|
activity.queue_activity_number = len(activity.activity_queue_ids)
|
||||||
|
|
||||||
#lancer une fenetre pour inscritpion en file d'attente à partir du boutton
|
#lancer une fenetre pour inscritpion en file d'attente à partir du boutton
|
||||||
@api.multi
|
@api.multi
|
||||||
def queue_register(self):
|
def queue_register(self):
|
||||||
|
""" launch a wizard to register in queue """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
activity_id = self[0]
|
activity_id = self[0]
|
||||||
return {
|
return {
|
||||||
@ -173,7 +179,7 @@ class GolemActivity(models.Model):
|
|||||||
'type' : 'ir.actions.act_window',
|
'type' : 'ir.actions.act_window',
|
||||||
'res_model' : 'golem.activity.queue',
|
'res_model' : 'golem.activity.queue',
|
||||||
'context' :{'default_activity_id' : activity_id.id},
|
'context' :{'default_activity_id' : activity_id.id},
|
||||||
'domain' : [('activity_id', '=', activity_id.id)],# activity_id.name)],#"('activity_id', '=', True)"
|
'domain' : [('activity_id', '=', activity_id.id)],
|
||||||
'view_mode': 'tree',
|
'view_mode': 'tree',
|
||||||
'flags': {'action_buttons': True},
|
'flags': {'action_buttons': True},
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
@ -182,6 +188,7 @@ class GolemActivity(models.Model):
|
|||||||
#fonction enregistrement du premier element de la liste d'ttente en inscription : mode manuel
|
#fonction enregistrement du premier element de la liste d'ttente en inscription : mode manuel
|
||||||
@api.multi
|
@api.multi
|
||||||
def register_from_queue(self):
|
def register_from_queue(self):
|
||||||
|
""" register member from queue"""
|
||||||
for record in self:
|
for record in self:
|
||||||
#recupérer la liste en file d'attente
|
#recupérer la liste en file d'attente
|
||||||
queues = record.activity_queue_ids
|
queues = record.activity_queue_ids
|
||||||
@ -195,7 +202,8 @@ class GolemActivity(models.Model):
|
|||||||
membre_registred = False
|
membre_registred = False
|
||||||
#recuperer la liste des registration
|
#recuperer la liste des registration
|
||||||
registrations = record.activity_registration_ids
|
registrations = record.activity_registration_ids
|
||||||
#parcourir les registration afin de vérifier si le memebre sur l'attente déja inscrit
|
#parcourir les registration afin de vérifier si le memebre sur
|
||||||
|
#l'attente déja inscrit
|
||||||
for registration in registrations:
|
for registration in registrations:
|
||||||
#compare le membre sur l'attente au membre sur l'inscription
|
#compare le membre sur l'attente au membre sur l'inscription
|
||||||
if queue.member_id == registration.member_id:
|
if queue.member_id == registration.member_id:
|
||||||
@ -203,7 +211,8 @@ class GolemActivity(models.Model):
|
|||||||
record.activity_queue_ids = [(2, queue.id, 0)]
|
record.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
# on mentionne enregistré, on passe au registration suivante
|
# on mentionne enregistré, on passe au registration suivante
|
||||||
membre_registred = True
|
membre_registred = True
|
||||||
#on sort de la boucle de registration et on passe à l'element suivant de l'attente
|
#on sort de la boucle de registration et on passe à
|
||||||
|
#l'element suivant de l'attente
|
||||||
break
|
break
|
||||||
#à la sortie de la boucle si le membre nest pas sur inscription faire une
|
#à la sortie de la boucle si le membre nest pas sur inscription faire une
|
||||||
if not membre_registred:
|
if not membre_registred:
|
||||||
@ -213,7 +222,7 @@ class GolemActivity(models.Model):
|
|||||||
'member_id' : queue.member_id
|
'member_id' : queue.member_id
|
||||||
}
|
}
|
||||||
# creation d'inscription
|
# creation d'inscription
|
||||||
record.activity_registration_ids = [(0, 0,values)]
|
record.activity_registration_ids = [(0, 0, values)]
|
||||||
#suppression de l'element de la file d'attente
|
#suppression de l'element de la file d'attente
|
||||||
record.activity_queue_ids = [(2, queue.id, 0)]
|
record.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
#sortir de la boucle parcourissante la queue puisque inscription faite
|
#sortir de la boucle parcourissante la queue puisque inscription faite
|
||||||
@ -227,12 +236,12 @@ class GolemActivity(models.Model):
|
|||||||
#2 verifier si desincription donc place disponible pour queue(automatique ou manuel)
|
#2 verifier si desincription donc place disponible pour queue(automatique ou manuel)
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.onchange('activity_registration_ids')
|
@api.onchange('activity_registration_ids')
|
||||||
def _checkRegistrationNumber(self):
|
def _check_registration_number(self):
|
||||||
current_activity = self._origin
|
current_activity = self._origin
|
||||||
for record in self:
|
for record in self:
|
||||||
#warning au cas ou le nombre d'inscription depasse le nombre de place
|
#warning au cas ou le nombre d'inscription depasse le nombre de place
|
||||||
if (len(record.activity_registration_ids) > record.places and
|
if (len(record.activity_registration_ids) > record.places and
|
||||||
record.queue_allowed):
|
record.queue_allowed):
|
||||||
message = _('No remaining place for the activity : {}, please'
|
message = _('No remaining place for the activity : {}, please'
|
||||||
' discard changes and register in the queue using'
|
' discard changes and register in the queue using'
|
||||||
' the button bellow')
|
' the button bellow')
|
||||||
@ -244,29 +253,30 @@ class GolemActivity(models.Model):
|
|||||||
}
|
}
|
||||||
elif (len(record.activity_registration_ids) < len(current_activity.activity_registration_ids) and
|
elif (len(record.activity_registration_ids) < len(current_activity.activity_registration_ids) and
|
||||||
len(current_activity.activity_registration_ids) == record.places and
|
len(current_activity.activity_registration_ids) == record.places and
|
||||||
record.queue_activity_number > 0 ):
|
record.queue_activity_number > 0):
|
||||||
#si le mode d'inscription depuis attente est activé
|
#si le mode d'inscription depuis attente est activé
|
||||||
if record.automated_registration_from_queue:
|
if record.auto_registration_from_queue:
|
||||||
#lancer un warning informant que l'inscription automatique aura lieu apres sauvegarde
|
#lancer un warning informant que l'inscription automatique aura
|
||||||
print("________________________testuii____________________________________")
|
#lieu apres sauvegarde
|
||||||
warningMessage = _('There is a free place for the activity'
|
warning_message = _('There is a free place for the activity'
|
||||||
' : {}, once you save it will be filled'
|
' : {}, once you save it will be filled'
|
||||||
' by the first membre from queue')
|
' by the first membre from queue')
|
||||||
return {
|
return {
|
||||||
'warning' : {
|
'warning' : {
|
||||||
'title' : _('Warning'),
|
'title' : _('Warning'),
|
||||||
'message': warningMessage.format(record.name)
|
'message': warning_message.format(record.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#traitement manuel pour le passage de la file d'attente en inscription : button sur queue
|
#traitement manuel pour le passage de la file d'attente en inscription
|
||||||
else :
|
# : button sur queue
|
||||||
warningMessage = _('There is a free place for the activity'
|
else:
|
||||||
' : {}, you can fill it from the queue'
|
warning_message = _('There is a free place for the activity'
|
||||||
' using the button on queue tab')
|
' : {}, you can fill it from the queue'
|
||||||
|
' using the button on queue tab')
|
||||||
return {
|
return {
|
||||||
'warning' : {
|
'warning' : {
|
||||||
'title' : _('Warning'),
|
'title' : _('Warning'),
|
||||||
'message': warningMessage.format(record.name)
|
'message': warning_message.format(record.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class GolemActivityQueue(models.Model):
|
|||||||
#nombre de place disponible sur activité liée
|
#nombre de place disponible sur activité liée
|
||||||
places_remain = fields.Integer(related='activity_id.places_remain')
|
places_remain = fields.Integer(related='activity_id.places_remain')
|
||||||
#activité liée est plein ou non
|
#activité liée est plein ou non
|
||||||
is_activity_full = fields.Char(compute="_isActivityFull", store=True)
|
is_activity_full = fields.Char(compute="_compute_is_activity_full", store=True)
|
||||||
|
|
||||||
sequence = fields.Integer()
|
sequence = fields.Integer()
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class GolemActivityQueue(models.Model):
|
|||||||
|
|
||||||
# decider si l'activity liée est pleine ou non : pour group by sur la liste
|
# decider si l'activity liée est pleine ou non : pour group by sur la liste
|
||||||
@api.depends('places_remain')
|
@api.depends('places_remain')
|
||||||
def _isActivityFull(self):
|
def _compute_is_activity_full(self):
|
||||||
""" Decide if activity is full or not """
|
""" Decide if activity is full or not """
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.places_remain == 0:
|
if record.places_remain == 0:
|
||||||
|
@ -27,90 +27,83 @@ class GolemMember(models.Model):
|
|||||||
'member_id', 'Pending registration')
|
'member_id', 'Pending registration')
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, values):
|
def write(self, vals):
|
||||||
|
registrations_edited = vals.get('activity_registration_ids')
|
||||||
|
if registrations_edited:
|
||||||
|
for registration_edited in registrations_edited:
|
||||||
|
if registration_edited[0] == 2:
|
||||||
|
registration_removed = self.env['golem.activity.registration'].browse(registration_edited[1])
|
||||||
|
activity_removed = self.env['golem.activity'].browse(registration_removed.activity_id.id)
|
||||||
|
if (activity_removed.queue_allowed and
|
||||||
|
activity_removed.auto_registration_from_queue and
|
||||||
|
activity_removed.queue_activity_number > 0):
|
||||||
|
#récupérer la liste des attente lié à l'activité
|
||||||
|
queues = activity_removed.activity_queue_ids
|
||||||
|
#trier la liste selon l'id : récupérer l'ancien element
|
||||||
|
queues_sorted = sorted(queues, key=lambda k: k['id'])
|
||||||
|
#suppose que le membre est enrigistré
|
||||||
|
membre_registred = True
|
||||||
|
#parcourir les element sur l'attente
|
||||||
|
for queue in queues_sorted:
|
||||||
|
#inverse l'etat du memebre
|
||||||
|
membre_registred = False
|
||||||
|
#recuperer la liste des registration
|
||||||
|
registrations = activity_removed.activity_registration_ids
|
||||||
|
#parcourir les registration afin de vérifier si le memebre sur
|
||||||
|
#l'attente déja inscrit
|
||||||
|
for registration in registrations:
|
||||||
|
#compare le membre sur l'attente au membre sur l'inscription
|
||||||
|
if queue.member_id == registration.member_id:
|
||||||
|
#si membre trouvé inscrit sur l'activité on le
|
||||||
|
#supprime de la queue
|
||||||
|
activity_removed.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
|
#si membre trouvé on mentionne enregistré, on passe au
|
||||||
|
#registration suivante
|
||||||
|
membre_registred = True
|
||||||
|
break
|
||||||
|
#à la sortie de la boucle si le membre nest pas sur
|
||||||
|
#inscription faire une
|
||||||
|
if not membre_registred:
|
||||||
|
#valeures pour creer une inscritpion apartir de la file
|
||||||
|
values = {
|
||||||
|
'activity_id' : queue.activity_id,
|
||||||
|
'member_id' : queue.member_id
|
||||||
|
}
|
||||||
|
|
||||||
#comparer old with new
|
super(GolemMember, self).write(vals)
|
||||||
oldRegistrations = self.activity_registration_ids
|
# creation d'inscription
|
||||||
oldActivities = [oldRegistration.activity_id.id for oldRegistration in oldRegistrations]
|
activity_removed.activity_registration_ids = [(0, 0, values)]
|
||||||
|
#suppression de l'element de la file d'attente
|
||||||
super(GolemMember, self).write(values)
|
activity_removed.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
newRegistrations = self.activity_registration_ids
|
#afficher un message informatif
|
||||||
if len(oldRegistrations) > len(newRegistrations):
|
warning_message = _('There is a free place for the activity'
|
||||||
newActivities = [newRegistration.activity_id.id for newRegistration in newRegistrations]
|
' : {}, once you save it will be filled'
|
||||||
changed = list(set(oldActivities) - set(newActivities))
|
' by the first membre from queue')
|
||||||
activityRemoved = self.env['golem.activity'].browse(changed[0])
|
print warning_message.format(activity_removed.name)
|
||||||
|
#sortir de la boucle parcourissante la queue puisque
|
||||||
if (activityRemoved.queue_allowed and
|
# inscription faite
|
||||||
activityRemoved.automated_registration_from_queue and
|
break
|
||||||
activityRemoved.queue_activity_number > 0):
|
elif (activity_removed.queue_allowed and
|
||||||
queues = activityRemoved.activity_queue_ids
|
activity_removed.queue_activity_number > 0):
|
||||||
#trier la liste selon l'id : récupérer l'ancien element
|
warning_message = _('There is a free place for the activity'
|
||||||
queues_sorted = sorted(queues, key=lambda k: k['id'])
|
' : {}, you can fill it from the queue'
|
||||||
#suppose que le membre est enrigistré
|
' using the button on queue tab')
|
||||||
membre_registred = True
|
print warning_message.format(activity_removed.name)
|
||||||
#parcourir les element sur l'attente
|
|
||||||
for queue in queues_sorted:
|
|
||||||
#inverse l'etat du memebre
|
|
||||||
membre_registred = False
|
|
||||||
#recuperer la liste des registration
|
|
||||||
registrations = activityRemoved.activity_registration_ids
|
|
||||||
#parcourir les registration afin de vérifier si le memebre sur l'attente déja inscrit
|
|
||||||
for registration in registrations:
|
|
||||||
#compare le membre sur l'attente au membre sur l'inscription
|
|
||||||
if queue.member_id == registration.member_id:
|
|
||||||
#si membre trouvé inscrit sur l'activité on le supprime de la queue
|
|
||||||
record.activity_queue_ids = [(2, queue.id, 0)]
|
|
||||||
#si membre trouvé on mentionne enregistré, on passe au registration suivante
|
|
||||||
membre_registred = True
|
|
||||||
break
|
|
||||||
#à la sortie de la boucle si le membre nest pas sur inscription faire une
|
|
||||||
if not membre_registred:
|
|
||||||
#valeures pour creer une inscritpion apartir de la file
|
|
||||||
values = {
|
|
||||||
'activity_id' : queue.activity_id,
|
|
||||||
'member_id' : queue.member_id
|
|
||||||
}
|
|
||||||
# creation d'inscription
|
|
||||||
activityRemoved.activity_registration_ids = [(0, 0,values)]
|
|
||||||
#suppression de l'element de la file d'attente
|
|
||||||
activityRemoved.activity_queue_ids = [(2, queue.id, 0)]
|
|
||||||
#sortir de la boucle parcourissante la queue puisque inscription faite
|
|
||||||
break
|
|
||||||
|
|
||||||
warningMessage = _('There is a free place for the activity'
|
|
||||||
' : {}, once you save it will be filled'
|
|
||||||
' by the first membre from queue')
|
|
||||||
print warningMessage.format(activityRemoved.name)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
elif (activityRemoved.queue_allowed and
|
|
||||||
activityRemoved.queue_activity_number > 0) :
|
|
||||||
warningMessage = _('There is a free place for the activity'
|
|
||||||
' : {}, you can fill it from the queue'
|
|
||||||
' using the button on queue tab')
|
|
||||||
print warningMessage.format(activityRemoved.name)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.constrains('activity_registration_ids')
|
|
||||||
def _automatedRegistrationFromQueue(self):
|
|
||||||
""" Automated Registration From Queue"""
|
|
||||||
#verifier le nombre d'enregistr
|
|
||||||
"""for member in self:
|
|
||||||
for registration in member.activity_registration_ids:
|
|
||||||
print '______________________________________________'
|
|
||||||
print registration.activity_id.name"""
|
|
||||||
|
|
||||||
#verifier si nombre d'inscription sur activité est supérieur au place disponible
|
#verifier si nombre d'inscription sur activité est supérieur au place disponible
|
||||||
|
#inviter l'utilisateur à s'inscrire sur l'attente
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.onchange('activity_registration_ids')
|
@api.onchange('activity_registration_ids')
|
||||||
def _checkRegistrationNumber(self):
|
def _check_registration_number(self):
|
||||||
|
""" check activity registration number """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
member_id = self[0]
|
member_id = self[0]
|
||||||
|
#recupérer la liste des inscription pour le membbre courant
|
||||||
for registration in member_id.activity_registration_ids:
|
for registration in member_id.activity_registration_ids:
|
||||||
|
#recupérer l'activité liée
|
||||||
activity = registration.activity_id
|
activity = registration.activity_id
|
||||||
|
#vérifier si le nombre d'inscription depasse le nombre de places sur activité
|
||||||
if len(activity.activity_registration_ids) > activity.places and activity.queue_allowed:
|
if len(activity.activity_registration_ids) > activity.places and activity.queue_allowed:
|
||||||
warning_message = _('This activity : {} is already full, please'
|
warning_message = _('This activity : {} is already full, please'
|
||||||
' discard changes and register in'
|
' discard changes and register in'
|
||||||
@ -125,9 +118,10 @@ class GolemMember(models.Model):
|
|||||||
#lancer popup pour choisir activité à s'inscrire
|
#lancer popup pour choisir activité à s'inscrire
|
||||||
@api.multi
|
@api.multi
|
||||||
def choose_queue_to_register(self):
|
def choose_queue_to_register(self):
|
||||||
|
""" launch wizard to choose activity queue to register in"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
member_id = self[0]
|
member_id = self[0]
|
||||||
|
#lancer le wizard avec le membre actuel
|
||||||
return {
|
return {
|
||||||
'name' : _('Choose the activity to register in'),
|
'name' : _('Choose the activity to register in'),
|
||||||
'type' : 'ir.actions.act_window',
|
'type' : 'ir.actions.act_window',
|
||||||
|
@ -16,86 +16,81 @@ GNU Affero General Public License for more details.
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
|
|
||||||
<!--formulaire du modèle golem.activity.queue-->
|
<!--formulaire du modèle golem.activity.queue-->
|
||||||
<record model="ir.ui.view" id="queue_form_view">
|
<record model="ir.ui.view" id="queue_form_view">
|
||||||
<field name="name">queue.form</field>
|
<field name="name">queue.form</field>
|
||||||
<field name="model">golem.activity.queue</field>
|
<field name="model">golem.activity.queue</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Queue Form">
|
<form string="Queue Form">
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<field name="activity_id"/>
|
<field name="activity_id"/>
|
||||||
<field name="season_id"/>
|
<field name="season_id"/>
|
||||||
|
<field name="member_id"/>
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<!--Recherche du modèle golem.activity.queue-->
|
||||||
|
<record model="ir.ui.view" id="queue_search_view">
|
||||||
|
<field name="name">queue.search</field>
|
||||||
|
<field name="model">golem.activity.queue</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search >
|
||||||
<field name="member_id"/>
|
<field name="member_id"/>
|
||||||
</group>
|
<field name="activity_id"/>
|
||||||
</sheet>
|
<field name="season_id" />
|
||||||
</form>
|
<filter name="season_default" string="Default season"
|
||||||
</field>
|
domain="[('is_current', '=', True)]" />
|
||||||
</record>
|
<filter name="full_activity" string="Full Activity"
|
||||||
|
domain="[('is_activity_full', '=', 'Full activity')]" />
|
||||||
<!--Recherche du modèle golem.activity.queue-->
|
<filter name="not_full_activity" string="Not Full Activity"
|
||||||
<record model="ir.ui.view" id="queue_search_view">
|
domain="[('is_activity_full', '=', 'Not full activity')]" />
|
||||||
<field name="name">queue.search</field>
|
<group string="Group By">
|
||||||
<field name="model">golem.activity.queue</field>
|
<filter name="group_by_member" string="Member"
|
||||||
<field name="arch" type="xml">
|
context="{'group_by': 'member_id'}"/>
|
||||||
<search >
|
<filter name="group_by_activity" string="Activity"
|
||||||
<field name="member_id"/>
|
context="{'group_by': 'activity_id'}"/>
|
||||||
<field name="activity_id"/>
|
<filter name="group_by_is_full_activity" string="Activity full"
|
||||||
<field name="season_id" />
|
context="{'group_by': 'is_activity_full'}"/>
|
||||||
<filter name="season_default" string="Default season"
|
</group>
|
||||||
domain="[('is_current', '=', True)]" />
|
</search>
|
||||||
<filter name="full_activity" string="Full Activity"
|
</field>
|
||||||
domain="[('is_activity_full', '=', 'Full activity')]" />
|
</record>
|
||||||
<filter name="not_full_activity" string="Not Full Activity"
|
<!--liste editable du modèle golem.activity.queue-->
|
||||||
domain="[('is_activity_full', '=', 'Not full activity')]" />
|
<record model="ir.ui.view" id="queue_tree_view">
|
||||||
<group string="Group By">
|
<field name="name">queue.tree</field>
|
||||||
<filter name="group_by_member" string="Member"
|
<field name="model">golem.activity.queue</field>
|
||||||
context="{'group_by': 'member_id'}"/>
|
<field name="arch" type="xml">
|
||||||
<filter name="group_by_activity" string="Activity"
|
<tree string="Queue Tree"
|
||||||
context="{'group_by': 'activity_id'}"/>
|
editable="top"
|
||||||
<filter name="group_by_is_full_activity" string="Activity full"
|
colors="grey: places_remain == 0; blue : places_remain >= 1">
|
||||||
context="{'group_by': 'is_activity_full'}"/>
|
<field name="sequence" widget="handle"/>
|
||||||
</group>
|
<field name="member_id"/>
|
||||||
</search>
|
<field name="activity_id"
|
||||||
</field>
|
domain="[('places_remain','<' , 1), ('queue_allowed', '=', True), ('is_current', '=', True)]"
|
||||||
</record>
|
options="{'no_create': True}"/>
|
||||||
<!--liste editable du modèle golem.activity.queue-->
|
<field name="season_id" readonly='1'/>
|
||||||
<record model="ir.ui.view" id="queue_tree_view">
|
<field name="create_date" readonly="1"/>
|
||||||
<field name="name">queue.tree</field>
|
<field name='places_remain' />
|
||||||
<field name="model">golem.activity.queue</field>
|
<field name="is_activity_full" />
|
||||||
<field name="arch" type="xml">
|
</tree>
|
||||||
<tree string="Queue Tree" editable="top" colors="grey: places_remain == 0; blue : places_remain >= 1">
|
</field>
|
||||||
<field name="sequence" widget="handle"/>
|
</record>
|
||||||
<field name="member_id"/>
|
<!-- Action -->
|
||||||
<field name="activity_id"
|
<record id="golem_activity_queue_action" model="ir.actions.act_window">
|
||||||
domain="[('places_remain','<' , 1), ('queue_allowed', '=', True), ('is_current', '=', True)]"
|
<field name="name">GOLEM Activity Queue List</field>
|
||||||
options="{'no_create': True}"/>
|
<field name="res_model">golem.activity.queue</field>
|
||||||
<field name="season_id" readonly='1'/>
|
<field name="view_mode">tree,search</field>
|
||||||
<field name="create_date" readonly="1"/>
|
<field name="context">{'search_default_season_default': True}</field>
|
||||||
<field name='places_remain' />
|
</record>
|
||||||
<field name="is_activity_full" />
|
<!-- Menu -->
|
||||||
</tree>
|
<menuitem id="golem_activity_queue_menu" name="Activity queue"
|
||||||
</field>
|
parent="golem_activity.golem_activity_menu"
|
||||||
</record>
|
action="golem_activity_queue_action"
|
||||||
|
sequence="20" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Action -->
|
|
||||||
<record id="golem_activity_queue_action" model="ir.actions.act_window">
|
|
||||||
<field name="name">GOLEM Activity Queue List</field>
|
|
||||||
<field name="res_model">golem.activity.queue</field>
|
|
||||||
<field name="view_mode">tree,search</field>
|
|
||||||
<field name="context">{'search_default_season_default': True}</field>
|
|
||||||
</record>
|
|
||||||
<!-- Menu -->
|
|
||||||
<menuitem id="golem_activity_queue_menu" name="Activity queue"
|
|
||||||
parent="golem_activity.golem_activity_menu"
|
|
||||||
action="golem_activity_queue_action"
|
|
||||||
sequence="20" />
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -16,19 +16,18 @@ GNU Affero General Public License for more details.
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
<record id="golem_activity_form_inherit_golem_activity_queue"
|
<record id="golem_activity_form_inherit_golem_activity_queue"
|
||||||
model="ir.ui.view">
|
model="ir.ui.view">
|
||||||
<field name="name">Add the queue registration button to activity form</field>
|
<field name="name">Add the queue registration items to activity form</field>
|
||||||
<field name="model">golem.activity</field>
|
<field name="model">golem.activity</field>
|
||||||
<field name="inherit_id" ref="golem_activity.golem_activity_form" />
|
<field name="inherit_id" ref="golem_activity.golem_activity_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<!--Ajout du case file d'attente et inscription automatisé sur activity form-->
|
<!--Ajout du case file d'attente et inscription automatisé sur activity form-->
|
||||||
<xpath expr="//field[@name='is_overbooked']" position="after">
|
<xpath expr="//field[@name='is_overbooked']" position="after">
|
||||||
<field name="queue_allowed" readonly='1'/>
|
<field name="queue_allowed" readonly='1'/>
|
||||||
<field name="automated_registration_from_queue" readonly='1'/>
|
<field name="auto_registration_from_queue" readonly='1'/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<!--Ajout du bouton inscription en file d'attente sur activity form-->
|
<!--Ajout du bouton inscription en file d'attente sur activity form-->
|
||||||
<xpath expr="//field[@name='activity_registration_ids']" position="after">
|
<xpath expr="//field[@name='activity_registration_ids']" position="after">
|
||||||
@ -38,33 +37,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<button class="oe_highlight" name="register_from_queue"
|
<button class="oe_highlight" name="register_from_queue"
|
||||||
string="Register from Queue" type="object"
|
string="Register from Queue" type="object"
|
||||||
attrs="{'invisible':[('places_remain','<', 1)]}"/>
|
attrs="{'invisible':[('places_remain','<', 1)]}"/>
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<!--Ajout onglet queue sur activity form-->
|
<!--Ajout onglet queue sur activity form-->
|
||||||
<xpath expr="//page[@name='invoicing']" position="before">
|
<xpath expr="//page[@name='invoicing']" position="before">
|
||||||
<page name="queue" string="Queue" attrs="{'invisible': [('queue_allowed', '=', False)]}">
|
<page name="queue" string="Queue" attrs="{'invisible': [('queue_allowed', '=', False)]}">
|
||||||
<group>
|
<group>
|
||||||
<field name="queue_activity_number" readonly='1'/>
|
<field name="queue_activity_number" readonly='1'/>
|
||||||
<field name="activity_queue_ids"
|
<field name="activity_queue_ids"
|
||||||
context="{'default_activity_id': active_id}" >
|
context="{'default_activity_id': active_id}" >
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
<field name="sequence" widget="handle"/>
|
<field name="sequence" widget="handle"/>
|
||||||
<field name="member_id"/>
|
<field name="member_id"/>
|
||||||
<!-- domain="[('season_ids', '=', season_id)]" /> -->
|
|
||||||
<field name="activity_id" readonly="1" />
|
<field name="activity_id" readonly="1" />
|
||||||
<field name="season_id" readonly="1" />
|
<field name="season_id" readonly="1" />
|
||||||
</tree>
|
</tree>
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<button class="oe_highlight" name="register_from_queue"
|
<button class="oe_highlight" name="register_from_queue"
|
||||||
string="Register from Queue" type="object"/>
|
string="Register from Queue" type="object"/>
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
<!--Ajout du bouton "ajouter une file"-->
|
<!--Ajout du bouton "ajouter une file,supprimer file, automated et manual registration-->
|
||||||
<xpath expr="//header" position="inside">
|
<xpath expr="//header" position="inside">
|
||||||
<button class="oe_highlight" name="queue_allowed_toggle"
|
<button class="oe_highlight" name="queue_allowed_toggle"
|
||||||
string="Add Queue" type="object"
|
string="Add Queue" type="object"
|
||||||
@ -73,17 +68,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
string="Remove Queue" type="object"
|
string="Remove Queue" type="object"
|
||||||
attrs="{'invisible': [('queue_allowed', '=', False)]}"
|
attrs="{'invisible': [('queue_allowed', '=', False)]}"
|
||||||
confirm="Are you sure you want to remove queue from this activity ? This will delete all elements currently registred in"/>
|
confirm="Are you sure you want to remove queue from this activity ? This will delete all elements currently registred in"/>
|
||||||
<button class="oe_highlight" name="automated_registration_from_queue_toggle"
|
<button class="oe_highlight" name="auto_registration_from_queue_toggle"
|
||||||
string="Automated registration from queue" type="object"
|
string="Automated registration from queue" type="object"
|
||||||
attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&', ('queue_allowed', '=', True), ('automated_registration_from_queue', '=', True)]}"
|
attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&', ('queue_allowed', '=', True), ('auto_registration_from_queue', '=', True)]}"
|
||||||
confirm="Are you sure you want to switch to automated registration from queue mode ?"/>
|
confirm="Are you sure you want to switch to automated registration from queue mode ?"/>
|
||||||
<button class="oe_highlight" name="automated_registration_from_queue_toggle"
|
<button class="oe_highlight" name="auto_registration_from_queue_toggle"
|
||||||
string="Manual registration from queue" type="object"
|
string="Manual registration from queue" type="object"
|
||||||
attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&', ('queue_allowed', '=', True), ('automated_registration_from_queue', '=', False)]}"
|
attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&', ('queue_allowed', '=', True), ('auto_registration_from_queue', '=', False)]}"
|
||||||
confirm="Are you sure you want to switch to manual registration from queue mode ?"/>
|
confirm="Are you sure you want to switch to manual registration from queue mode ?"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
</data>
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -18,8 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
<!-- add the queue registration items to member form-->
|
||||||
<!-- add the queue registration button to member form-->
|
|
||||||
<record id="golem_member_form_inherit_golem_activity_queue"
|
<record id="golem_member_form_inherit_golem_activity_queue"
|
||||||
model="ir.ui.view">
|
model="ir.ui.view">
|
||||||
<field name="name">Add the queue onglet and registration button to member form</field>
|
<field name="name">Add the queue onglet and registration button to member form</field>
|
||||||
@ -36,7 +35,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<page name="activities" position="after">
|
<page name="activities" position="after">
|
||||||
<page name="queue" string="List of queues">
|
<page name="queue" string="List of queues">
|
||||||
<group>
|
<group>
|
||||||
|
|
||||||
<field name="activity_queue_ids"
|
<field name="activity_queue_ids"
|
||||||
context="{'default_member_id': active_id}">
|
context="{'default_member_id': active_id}">
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
|
|
||||||
""" GOLEM Resources management """
|
""" GOLEM Resources management """
|
||||||
|
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields
|
||||||
|
|
||||||
class GolemActivityAutomatedQueueActivateWizard(models.TransientModel):
|
class GolemActivityAutomatedQueueActivateWizard(models.TransientModel):
|
||||||
"""GOLEM Activity Automated Queue wizard : Activatate automated Queue """
|
"""GOLEM Activity Automated Queue wizard : Activatate automated Queue """
|
||||||
_name = "golem.activity.automated.queue.activate.wizard"
|
_name = "golem.activity.automated.queue.activate.wizard"
|
||||||
|
|
||||||
activity_id = fields.Many2one("golem.activity")
|
activity_id = fields.Many2one("golem.activity")
|
||||||
automated_registration_from_queue = fields.Boolean(default=True)
|
auto_registration_from_queue = fields.Boolean(default=True)
|
||||||
|
|
||||||
|
|
||||||
# lancer liste editable d'inscription sur attente
|
# lancer liste editable d'inscription sur attente
|
||||||
@ -36,7 +36,7 @@ class GolemActivityAutomatedQueueActivateWizard(models.TransientModel):
|
|||||||
activation = self[0]
|
activation = self[0]
|
||||||
activation.activity_id.write({
|
activation.activity_id.write({
|
||||||
'queue_allowed': True,
|
'queue_allowed': True,
|
||||||
'automated_registration_from_queue': activation.automated_registration_from_queue
|
'auto_registration_from_queue': activation.auto_registration_from_queue
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="activity_id" invisible="1" />
|
<field name="activity_id" invisible="1" />
|
||||||
<field name="automated_registration_from_queue"/>
|
<field name="auto_registration_from_queue"/>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="activate_queue" string="Confirm" type="object"
|
<button name="activate_queue" string="Confirm" type="object"
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
""" GOLEM Resources management """
|
""" GOLEM Resources management """
|
||||||
|
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, _
|
||||||
|
|
||||||
class GolemActivityQueueChooseWizard(models.TransientModel):
|
class GolemActivityQueueChooseWizard(models.TransientModel):
|
||||||
"""GOLEM Resource wizard : rchoose activity queue to register in """
|
"""GOLEM Resource wizard : rchoose activity queue to register in """
|
||||||
@ -31,15 +31,14 @@ class GolemActivityQueueChooseWizard(models.TransientModel):
|
|||||||
def register_in_queue(self):
|
def register_in_queue(self):
|
||||||
""" Choisir l'activité pour s'inscrire sur sa liste d'attente"""
|
""" Choisir l'activité pour s'inscrire sur sa liste d'attente"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
activityQueue = self[0]
|
activity_queue = self[0]
|
||||||
self.env['golem.activity.queue'].create({'member_id': activityQueue.member_id.id,
|
self.env['golem.activity.queue'].create({'member_id': activity_queue.member_id.id,
|
||||||
'activity_id': activityQueue.activity_id.id})
|
'activity_id': activity_queue.activity_id.id})
|
||||||
message = _('the member {} is registred in queue for the activity {} with success')
|
message = _('the member {} is registred in queue for the activity {} with success')
|
||||||
return {
|
return {
|
||||||
'warning' : {
|
'warning' : {
|
||||||
'title' : _('Warning'),
|
'title' : _('Warning'),
|
||||||
'message': (message.format(activityQueue.member_id.name,
|
'message': (message.format(activity_queue.member_id.name,
|
||||||
activityQueue.activity_id.name))
|
activity_queue.activity_id.name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,8 @@ GNU Affero General Public License for more details.
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<!-- Forms -->
|
<!-- Forms -->
|
||||||
<record model="ir.ui.view" id="golem_activity_queue_choose_wizard_view_form">
|
<record model="ir.ui.view" id="golem_activity_queue_choose_wizard_view_form">
|
||||||
<field name="name">GOLEM Activity Queue Choose Wizard Form</field>
|
<field name="name">GOLEM Activity Queue Choose Wizard Form</field>
|
||||||
@ -39,8 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
Loading…
Reference in New Issue
Block a user