From 9fdb1cbddc9ce71a10f158831e9afccd4078133c Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Mon, 19 Feb 2018 14:03:13 +0100 Subject: [PATCH] Ajout warning au cas de depassement de place --- .../models/golem_activity_queue.py | 67 ++++++++++++++----- .../views/golem_activity_queue_views.xml | 39 ++++++++++- .../views/golem_activity_views.xml | 12 ++-- 3 files changed, 94 insertions(+), 24 deletions(-) diff --git a/golem_activity_queue/models/golem_activity_queue.py b/golem_activity_queue/models/golem_activity_queue.py index ad3a43d..7c70bfc 100644 --- a/golem_activity_queue/models/golem_activity_queue.py +++ b/golem_activity_queue/models/golem_activity_queue.py @@ -24,16 +24,23 @@ class YesNoQueuePopUp(models.TransientModel): _name = "golem.queuepopup" - yes_no = fields.Char(default='Do you want to proceed?') + #yes_no = fields.Char(default='Do you want to proceed?') @api.multi - def yes(self): - pass - # sure continue! + def queueYes(self): + print "########################################################" + return { + 'name' : _('Do you want to add your registration to the queue?'), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.activity.queue', + 'view_mode': 'form', + 'view_type': 'form', + 'target': 'new', + } @api.multi - def no(self): - pass # don't do anything stupid + def queueNo(self): + pass # don't do anything class GolemActivity(models.Model): @@ -46,39 +53,53 @@ class GolemActivity(models.Model): # un boolen pour determiner si une fille d'attente est autorisé queue_allowed = fields.Boolean(default=True) + def queue_register(self): + return { + 'name' : _('Register in the queue'), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.activity.queue', + 'view_mode': 'form', + 'view_type': 'form', + 'target': 'new', + } + + @api.onchange('activity_registration_ids') + def _checkRemain(self): + + if len(self.activity_registration_ids) > self.places and self.queue_allowed: + return { + 'warning' : { + 'title' : _('Warning'), + 'message': _('No remaining place, please register in the queue'), + } + } + + """ @api.multi @api.constrains('places_remain') def _check_remaining_places(self): - """ Forbid inscription when there is no more place """ + #Forbid inscription when there is no more place for activity in self: if activity.places_remain < 5: if self.queue_allowed: print "__________________________ test ______________________" - return { - 'name' : _('Please enter the reseaon of rejection'), - 'type' : 'ir.actions.act_window', - 'res_model' : 'golem.queuepopup', - 'view_mode': 'form', - 'view_type': 'form', - 'target': 'new', - } - return { 'name' : _('Do you want to add your registration to the queue?'), 'type' : 'ir.actions.act_window', - 'res_model' : 'golem.queuepopup', + 'res_model' : 'golem.activity.queue', 'view_mode': 'form', 'view_type': 'form', 'target': 'new', } print "________________________________test 2 __________________" + raise models.ValidationError("erreur") else: emsg = _('Sorry, there is no more place man !') raise models.ValidationError(emsg) - +""" @@ -91,3 +112,13 @@ class GolemActivityQueue(models.Model): activity_id = fields.Many2one('golem.activity', required=True) season_id = fields.Many2one(related='activity_id.season_id') member_id = fields.Many2one('golem.member', required=True) + + 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', + } diff --git a/golem_activity_queue/views/golem_activity_queue_views.xml b/golem_activity_queue/views/golem_activity_queue_views.xml index 0ab8d6f..3ec3536 100644 --- a/golem_activity_queue/views/golem_activity_queue_views.xml +++ b/golem_activity_queue/views/golem_activity_queue_views.xml @@ -20,7 +20,44 @@ along with this program. If not, see . - + + + queue.form + golem.activity.queue + +
+ + + + + + + +
+
+
+ + + +queue.tree +golem.activity.queue + + + + + + + + + + + Resources Type + golem.activity.queue + form + + + +
diff --git a/golem_activity_queue/views/golem_activity_views.xml b/golem_activity_queue/views/golem_activity_views.xml index d259888..c8b1be5 100644 --- a/golem_activity_queue/views/golem_activity_views.xml +++ b/golem_activity_queue/views/golem_activity_views.xml @@ -27,6 +27,9 @@ along with this program. If not, see . + +