Ajout de fonction qui supprime les elemetes inscrit en attente en cas de désactivation de l'attente

This commit is contained in:
eloyoussef 2018-02-27 16:30:45 +01:00
parent 08c949d6e2
commit 1b3a187543
3 changed files with 17 additions and 5 deletions

View File

@ -72,10 +72,19 @@ class GolemActivity(models.Model):
#Ajouter/supprimer une file à l'activité et afficher popup pour traitement automatisé
@api.multi
def queue_allowed_toggle(self):
""" Toggle queue_alowed boolean """
for activity in self:
#si l'activité contient une file
if activity.queue_allowed:
activity.queue_allowed = not activity.queue_allowed
# si la queue déja contient des elements à supprimer
if len(activity.activity_queue_ids) > 0:
#parcourir et supprimer les element de la queue
for queue in activity.activity_queue_ids:
activity.activity_queue_ids = [(2, queue.id, 0)]
#changer l'état de queue allowed et automated_registration en false
activity.queue_allowed = False
activity.automated_registration_from_queue = False
else:
activity.queue_allowed = not activity.queue_allowed

View File

@ -52,13 +52,14 @@ class GolemActivityQueue(models.Model):
# decider si l'activity liée est pleine ou non : pour group by sur la liste
@api.depends('places_remain')
def _isActivityFull(self):
print "_____________________________________lklkkaaaa"
""" Decide if activity is full or not """
for record in self:
if record.places_remain == 0:
record.is_activity_full = "Full activity"
else:
record.is_activity_full = "Not full activity"
@api.constrains('member_id')
@api.constrains('member_id', 'activity_id')
def _check_member_registration(self):
""" Forbid registration in queue when member is already registred in the
activity """

View File

@ -66,10 +66,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<xpath expr="//header" position="inside">
<button class="oe_highlight" name="queue_allowed_toggle"
string="Add Queue" type="object"
attrs="{'invisible': [('queue_allowed', '=', True)]}"/>
attrs="{'invisible': [('queue_allowed', '=', True)]}"
confirm="Are you sure you want to do this?"/>
<button class="oe_highlight" name="queue_allowed_toggle"
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"/>
</xpath>
</field>
</record>