forked from Yaltik/golem
ajout du fonction qui empeche l'inscritption en queue si une inscription existe
This commit is contained in:
parent
0d4e819e5d
commit
d479a0ca45
@ -33,9 +33,15 @@ class GolemActivity(models.Model):
|
||||
automated_registration_from_queue = fields.Boolean(default=True)
|
||||
#ajout d'un champs pour calculer le nombre d'inscription en file d'attente
|
||||
queue_activity_number = fields.Integer(compute="_queue_activity_number",
|
||||
store=True , string='Pending registration number')
|
||||
store=True, string='Pending registration number')
|
||||
|
||||
|
||||
#Ajouter/supprimer une file à l'activité et afficher popup pour traitement automatisé
|
||||
@api.multi
|
||||
def queue_allowed_toggle(self):
|
||||
for activity in self:
|
||||
activity.queue_allowed = not activity.queue_allowed
|
||||
|
||||
#contraint sur nombre d'inscription : une desincription declanche une inscription depuis attente
|
||||
@api.multi
|
||||
@api.constrains('activity_registration_ids')
|
||||
|
@ -19,10 +19,12 @@
|
||||
""" GOLEM activities related models """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class GolemActivityQueue(models.Model):
|
||||
""" GOLEM Activity Queue """
|
||||
_name = 'golem.activity.queue'
|
||||
_order = "sequence"
|
||||
_description = 'GOLEM Activity Queue'
|
||||
|
||||
activity_id = fields.Many2one('golem.activity', required=True,
|
||||
@ -48,3 +50,16 @@ class GolemActivityQueue(models.Model):
|
||||
record.is_activity_full = "Full activity"
|
||||
else:
|
||||
record.is_activity_full = "Not full activity"
|
||||
@api.constrains('member_id')
|
||||
def _check_member_registration(self):
|
||||
""" Forbid registration in queue when member is already registred in the
|
||||
activity """
|
||||
for queue in self:
|
||||
domain = [('member_id', '=', queue.member_id.id),
|
||||
('activity_id', '=', queue.activity_id.id)]
|
||||
#verifier si un enrigistrement avec le meme membre et activité est déja fait
|
||||
registrations = self.env['golem.activity.registration'].search(domain)
|
||||
#si oui lancer un erreur
|
||||
if len(registrations):
|
||||
raise ValidationError(_('The member your trying to add to the queue'
|
||||
' is already registred for this activity'))
|
||||
|
@ -24,7 +24,7 @@ class GolemMember(models.Model):
|
||||
|
||||
#ajout d'un champs O2M vers member_id de golem.activity.queue
|
||||
activity_queue_ids = fields.One2many('golem.activity.queue',
|
||||
'member_id','Pending registration')
|
||||
'member_id', 'Pending registration')
|
||||
|
||||
#verifier si nombre d'inscription sur activité est supérieur au place disponible
|
||||
@api.multi
|
||||
@ -34,7 +34,7 @@ class GolemMember(models.Model):
|
||||
member_id = self[0]
|
||||
|
||||
for registration in member_id.activity_registration_ids:
|
||||
activity = reservation.activity_id
|
||||
activity = registration.activity_id
|
||||
if len(activity.activity_registration_ids) > activity.places and activity.queue_allowed:
|
||||
warning_message = _('This activity : {} is already full, please'
|
||||
' discard changes and register in'
|
||||
|
@ -67,7 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<tree string="Queue Tree" editable="top" colors="grey: places_remain == 0; blue : places_remain >= 1">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="member_id"/>
|
||||
<field name="activity_id" readonly='1'/>
|
||||
<field name="activity_id"/>
|
||||
<field name="season_id" readonly='1'/>
|
||||
<field name="create_date" readonly="1"/>
|
||||
<field name='places_remain' />
|
||||
|
@ -40,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
</xpath>
|
||||
<!--Ajout onglet queue sur activity form-->
|
||||
<page name="invoicing" position="before">
|
||||
<xpath expr="//page[@name='invoicing']" position="before">
|
||||
<page name="queue" string="Queue">
|
||||
<group>
|
||||
<field name="queue_activity_number" readonly='1'/>
|
||||
@ -61,7 +61,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
string="Register from Queue" type="object"/>
|
||||
</group>
|
||||
</page>
|
||||
</page>
|
||||
</xpath>
|
||||
<!--Ajout du bouton "ajouter une file"-->
|
||||
<xpath expr="//header" position="inside">
|
||||
<button class="oe_highlight" name="queue_allowed_toggle"
|
||||
string="Add Queue" type="object"
|
||||
attrs="{'invisible': [('queue_allowed', '=', True)]}"/>
|
||||
<button class="oe_highlight" name="queue_allowed_toggle"
|
||||
string="Remove Queue" type="object"
|
||||
attrs="{'invisible': [('queue_allowed', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user