Amélioration du fonction de basculement automatique depuis membre : utilisation vals

This commit is contained in:
eloyoussef 2018-02-28 02:06:26 +01:00
parent 3ab701c8d4
commit e4596cbda0
10 changed files with 221 additions and 235 deletions

View File

@ -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):
@ -118,7 +120,7 @@ class GolemActivity(models.Model):
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,7 +236,7 @@ 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
@ -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:
warning_message = _('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 on queue tab') ' 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)
} }
} }

View File

@ -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:

View File

@ -27,23 +27,18 @@ 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')
#comparer old with new if registrations_edited:
oldRegistrations = self.activity_registration_ids for registration_edited in registrations_edited:
oldActivities = [oldRegistration.activity_id.id for oldRegistration in oldRegistrations] if registration_edited[0] == 2:
registration_removed = self.env['golem.activity.registration'].browse(registration_edited[1])
super(GolemMember, self).write(values) activity_removed = self.env['golem.activity'].browse(registration_removed.activity_id.id)
newRegistrations = self.activity_registration_ids if (activity_removed.queue_allowed and
if len(oldRegistrations) > len(newRegistrations): activity_removed.auto_registration_from_queue and
newActivities = [newRegistration.activity_id.id for newRegistration in newRegistrations] activity_removed.queue_activity_number > 0):
changed = list(set(oldActivities) - set(newActivities)) #récupérer la liste des attente lié à l'activité
activityRemoved = self.env['golem.activity'].browse(changed[0]) queues = activity_removed.activity_queue_ids
if (activityRemoved.queue_allowed and
activityRemoved.automated_registration_from_queue and
activityRemoved.queue_activity_number > 0):
queues = activityRemoved.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
queues_sorted = sorted(queues, key=lambda k: k['id']) queues_sorted = sorted(queues, key=lambda k: k['id'])
#suppose que le membre est enrigistré #suppose que le membre est enrigistré
@ -53,64 +48,62 @@ class GolemMember(models.Model):
#inverse l'etat du memebre #inverse l'etat du memebre
membre_registred = False membre_registred = False
#recuperer la liste des registration #recuperer la liste des registration
registrations = activityRemoved.activity_registration_ids registrations = activity_removed.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
record.activity_queue_ids = [(2, queue.id, 0)] #supprime de la queue
#si membre trouvé on mentionne enregistré, on passe au registration suivante activity_removed.activity_queue_ids = [(2, queue.id, 0)]
#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
if not membre_registred: if not membre_registred:
#valeures pour creer une inscritpion apartir de la file #valeures pour creer une inscritpion apartir de la file
values = { values = {
'activity_id' : queue.activity_id, 'activity_id' : queue.activity_id,
'member_id' : queue.member_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' super(GolemMember, self).write(vals)
# creation d'inscription
activity_removed.activity_registration_ids = [(0, 0, values)]
#suppression de l'element de la file d'attente
activity_removed.activity_queue_ids = [(2, queue.id, 0)]
#afficher un message informatif
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')
print warningMessage.format(activityRemoved.name) print warning_message.format(activity_removed.name)
#sortir de la boucle parcourissante la queue puisque
# inscription faite
break
elif (activity_removed.queue_allowed and
elif (activityRemoved.queue_allowed and activity_removed.queue_activity_number > 0):
activityRemoved.queue_activity_number > 0) : warning_message = _('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 on queue tab') ' using the button on queue tab')
print warningMessage.format(activityRemoved.name) print warning_message.format(activity_removed.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',

View File

@ -16,13 +16,10 @@ 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">
@ -36,13 +33,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</sheet> </sheet>
</form> </form>
</field> </field>
</record> </record>
<!--Recherche du modèle golem.activity.queue-->
<!--Recherche du modèle golem.activity.queue--> <record model="ir.ui.view" id="queue_search_view">
<record model="ir.ui.view" id="queue_search_view"> <field name="name">queue.search</field>
<field name="name">queue.search</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">
<search > <search >
<field name="member_id"/> <field name="member_id"/>
<field name="activity_id"/> <field name="activity_id"/>
@ -62,14 +58,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
context="{'group_by': 'is_activity_full'}"/> context="{'group_by': 'is_activity_full'}"/>
</group> </group>
</search> </search>
</field> </field>
</record> </record>
<!--liste editable du modèle golem.activity.queue--> <!--liste editable du modèle golem.activity.queue-->
<record model="ir.ui.view" id="queue_tree_view"> <record model="ir.ui.view" id="queue_tree_view">
<field name="name">queue.tree</field> <field name="name">queue.tree</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">
<tree string="Queue Tree" editable="top" colors="grey: places_remain == 0; blue : places_remain &gt;= 1"> <tree string="Queue Tree"
editable="top"
colors="grey: places_remain == 0; blue : places_remain &gt;= 1">
<field name="sequence" widget="handle"/> <field name="sequence" widget="handle"/>
<field name="member_id"/> <field name="member_id"/>
<field name="activity_id" <field name="activity_id"
@ -80,11 +78,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name='places_remain' /> <field name='places_remain' />
<field name="is_activity_full" /> <field name="is_activity_full" />
</tree> </tree>
</field> </field>
</record> </record>
<!-- Action --> <!-- Action -->
<record id="golem_activity_queue_action" model="ir.actions.act_window"> <record id="golem_activity_queue_action" model="ir.actions.act_window">
<field name="name">GOLEM Activity Queue List</field> <field name="name">GOLEM Activity Queue List</field>

View File

@ -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,7 +37,6 @@ 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','&lt;', 1)]}"/> attrs="{'invisible':[('places_remain','&lt;', 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">
@ -50,21 +48,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<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),'&amp;', ('queue_allowed', '=', True), ('automated_registration_from_queue', '=', True)]}" attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&amp;', ('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),'&amp;', ('queue_allowed', '=', True), ('automated_registration_from_queue', '=', False)]}" attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&amp;', ('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>

View File

@ -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">

View File

@ -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
}) })

View File

@ -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"

View File

@ -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))
} }
} }

View File

@ -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>
@ -40,7 +38,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</form> </form>
</field> </field>
</record> </record>
</data> </data>
</odoo> </odoo>