forked from Yaltik/golem
amélioration de la fonction d'inscription automatique depuis la queue
This commit is contained in:
parent
9c7f5d9502
commit
83221ec706
@ -44,8 +44,13 @@ class GolemActivity(models.Model):
|
|||||||
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
|
#lancer une fenetre pour inscritpion en file d'attente
|
||||||
@api.multi
|
#@api.multi
|
||||||
def queue_register(self):
|
def queue_register(self):
|
||||||
|
print "______________________________________chmat-----------------"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
activity_id = self[0]
|
activity_id = self[0]
|
||||||
return {
|
return {
|
||||||
@ -105,7 +110,9 @@ class GolemActivity(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
@api.onchange('activity_registration_ids')
|
@api.onchange('activity_registration_ids')
|
||||||
def _checkRemain(self):
|
def _checkRemain(self):
|
||||||
|
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
|
||||||
if len(record.activity_registration_ids) > record.places and record.queue_allowed:
|
if len(record.activity_registration_ids) > record.places and 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'
|
||||||
@ -116,27 +123,47 @@ class GolemActivity(models.Model):
|
|||||||
'message': message.format(record.name),
|
'message': message.format(record.name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elif len(record.activity_registration_ids) < record.places and record.queue_allowed and record.queue_activity_number > 0:
|
elif (len(record.activity_registration_ids) < len(current_activity.activity_registration_ids) and
|
||||||
|
len(current_activity.activity_registration_ids) == record.places and
|
||||||
# passage de l'element depuis la file d'attente automatiquement
|
record.queue_activity_number > 0 ):
|
||||||
if record.automated_registration_from_queue:
|
if record.automated_registration_from_queue:
|
||||||
#traitement qui bloque avec message d'erreur can't adapt activitiy_id to newId
|
#inscription automatique du 1er element de la file d'attente
|
||||||
"""
|
print("________________________testuii____________________________________")
|
||||||
#recupérer la liste en file d'attente
|
#recupérer la liste en file d'attente
|
||||||
queues = record.activity_queue_ids
|
queues = current_activity.activity_queue_ids
|
||||||
|
print "______________________test1"
|
||||||
#trier la liste selon l'id : récupérer l'ancien element
|
#trier la liste selon l'id : récupérer l'ancien element
|
||||||
queues_sorted = sorted(queues, key=lambda k: k['id'])
|
queues_sorted = sorted(queues, key=lambda k: k['id'])
|
||||||
#valeures pour creer une inscritpion apartir de la file
|
print "______________________test1"
|
||||||
values = {
|
membre_registred = True
|
||||||
'activity_id' : queues_sorted[0].activity_id,
|
for queue in queues_sorted:
|
||||||
'member_id' : queues_sorted[0].member_id
|
print "______________________1"
|
||||||
}
|
membre_registred = False
|
||||||
# creation d'inscription
|
registrations = record.activity_registration_ids
|
||||||
record.activity_registration_ids = [(0, 0,values)]
|
for registration in registrations:
|
||||||
#suppression de l'element de la file d'attente
|
print "______________________2"
|
||||||
record.activity_queue_ids = [(2, queues_sorted[0].id, 0)]
|
if queue.member_id == registration.member_id:
|
||||||
|
membre_registred = True
|
||||||
|
break
|
||||||
|
if not membre_registred:
|
||||||
|
#valeures pour creer une inscritpion apartir de la file
|
||||||
|
print '_____________________creation'
|
||||||
|
values = {
|
||||||
|
'activity_id' : queue.activity_id,
|
||||||
|
'member_id' : queue.member_id
|
||||||
|
}
|
||||||
|
# creation d'inscription
|
||||||
|
record.places =55
|
||||||
|
record.activity_registration_ids = [(0, 0,values)]
|
||||||
|
#suppression de l'element de la file d'attente
|
||||||
|
record.activity_queue_ids = [(2, queue.id, 0)]
|
||||||
|
break
|
||||||
|
if membre_registred:
|
||||||
|
|
||||||
|
message = _('there is no member to register for this activity'
|
||||||
|
' from queue.')
|
||||||
|
raise ValidationError(message)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warningMessage = _('There is a free place for the activity'
|
warningMessage = _('There is a free place for the activity'
|
||||||
' : {}, you can fill it from the queue'
|
' : {}, you can fill it from the queue'
|
||||||
' using the button bellow')
|
' using the button bellow')
|
||||||
@ -146,7 +173,7 @@ class GolemActivity(models.Model):
|
|||||||
'message': warningMessage.format(record.name)
|
'message': warningMessage.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 : button sur queue
|
||||||
else :
|
else :
|
||||||
warningMessage = _('There is a free place for the activity'
|
warningMessage = _('There is a free place for the activity'
|
||||||
|
@ -33,23 +33,15 @@ 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="_isActivityFull")
|
||||||
|
|
||||||
# decider si l'activity liée est pleine ou non
|
# decider si l'activity liée est pleine ou non
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('places_remain')
|
@api.depends('places_remain')
|
||||||
def _isActivityFull(self):
|
def _isActivityFull(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.places_remain <=0:
|
if record.places_remain == 0:
|
||||||
record.is_activity_full = "Full activity"
|
record.is_activity_full = "Full activity"
|
||||||
else:
|
else:
|
||||||
record.is_activity_full = "Not full activity"
|
record.is_activity_full = "Not full activity"
|
||||||
def call_up_wizard(self):
|
|
||||||
return {
|
|
||||||
'name': 'Are you sure?',
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'res_model': 'golem.queuepopup',
|
|
||||||
'view_mode': 'form',
|
|
||||||
'view_type': 'form',
|
|
||||||
'target': 'new',
|
|
||||||
}
|
|
||||||
|
@ -70,6 +70,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="season_id" readonly='1'/>
|
<field name="season_id" readonly='1'/>
|
||||||
<field name="create_date" readonly="1"/>
|
<field name="create_date" readonly="1"/>
|
||||||
<field name='places_remain' />
|
<field name='places_remain' />
|
||||||
|
<field name="is_activity_full" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
Loading…
Reference in New Issue
Block a user