From c02cc886d4723aeb33a18ef14367bac990f34ebb Mon Sep 17 00:00:00 2001 From: Alicia FLOREZ Date: Wed, 12 Jun 2013 17:29:57 +0200 Subject: [PATCH] =?utf8?q?Ajout=20de=20boutons=20permettant=20le=20contr=C3=B4?= =?utf8?q?le=20de=20l'=C3=A9tat=20d'une=20=C3=A9volution?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- evolution.py | 103 ++++++++++++++++++++++++++++++++++++++++++++++++-- views/evolution.xml | 10 ++++- views/projet.xml | 2 +- wizards/evolution.py | 1 + 4 files changed, 110 insertions(+), 6 deletions(-) diff --git a/evolution.py b/evolution.py index 3c68f5c..4921278 100644 --- a/evolution.py +++ b/evolution.py @@ -31,7 +31,7 @@ class Evolution(osv.Model): "commentaire": fields.text(string="Commentaire"), "keywords": fields.text(string="Mots clés"), "priorite": fields.selection(_priorites, string="Priorité"), - "statut": fields.selection(_statuts, string="Statut"), + "state": fields.selection(_statuts, string="Statut"), # "charges": fields.one2many("cmmi.evolution.charge", # Supprimé ! # "evolution_id", # string="Charges"), @@ -49,8 +49,105 @@ class Evolution(osv.Model): domain=_domains['human']), } + _defaults = { + "state": "cree", + } -# ================================== PHASE ================================== # + def action_commencer(self, cr, uid, ids, context=None): + if type(ids) == list: + if len(ids) != 1: + return # TODO: message d'avertissement + ids = ids[0] + + evo = self.read(cr, uid, ids, ['state'], context) + + if evo['state'] != 'cree': + return + self.write( + cr, + uid, + ids, + {'state': 'encours'}, + context, + ) + return self + + def action_suspendre(self, cr, uid, ids, context=None): + if type(ids) == list: + if len(ids) != 1: + return # TODO: message d'avertissement + ids = ids[0] + + evo = self.read(cr, uid, ids, ['state'], context) + if evo['state'] != 'encours': + return + self.write( + cr, + uid, + ids, + {'state': 'suspendu'}, + context, + ) + return self + + def action_terminer(self, cr, uid, ids, context=None): + if type(ids) == list: + if len(ids) != 1: + return # TODO: message d'avertissement + ids = ids[0] + + evo = self.read(cr, uid, ids, ['state'], context) + if evo['state'] != 'encours': + return + self.write( + cr, + uid, + ids, + {'state': 'termine'}, + context, + ) + return self + + def action_abandonner(self, cr, uid, ids, context=None): + if type(ids) == list: + if len(ids) != 1: + return # TODO: message d'avertissement + ids = ids[0] + + evo = self.read(cr, uid, ids, ['state'], context) + + if not ('encours', 'cree').__contains__(evo['state']): + return + self.write( + cr, + uid, + ids, + {'state': 'abandonne'}, + context, + ) + return self + + def action_reprendre(self, cr, uid, ids, context=None): + if type(ids) == list: + if len(ids) != 1: + return # TODO: message d'avertissement + ids = ids[0] + + evo = self.read(cr, uid, ids, ['state'], context) + + if evo['state'] != 'suspendu': + return + self.write( + cr, + uid, + ids, + {'state': 'encours'}, + context, + ) + return self + + +# =========================== EVOLUTION PHASE =============================== # class Phase(osv.Model): _name = "cmmi.evolution.phase" @@ -100,7 +197,7 @@ class Phase(osv.Model): return osv.Model.create(self, cr, uid, vals, context=context) -# ================================== CHARGE ================================= # +# =========================== EVOLUTION CHARGE ============================== # class Charge(osv.Model): _name = "cmmi.evolution.charge" diff --git a/views/evolution.xml b/views/evolution.xml index e9c032e..0e5f8c5 100644 --- a/views/evolution.xml +++ b/views/evolution.xml @@ -8,14 +8,20 @@ cmmi.evolution
-
+
+
- + diff --git a/views/projet.xml b/views/projet.xml index 4040ff7..1b23a0c 100644 --- a/views/projet.xml +++ b/views/projet.xml @@ -124,7 +124,7 @@ - + diff --git a/wizards/evolution.py b/wizards/evolution.py index b901461..52b6414 100644 --- a/wizards/evolution.py +++ b/wizards/evolution.py @@ -88,6 +88,7 @@ class EvolutionWizard(osv.TransientModel): "description": res["description"], "objectif": res["objectif"], "commentaire": res["commentaire"], + "keywords": res["keywords"], "palier_id": res["palier_id"], "chantier_id": res["chantier_id"], "projet_id": res["projet_id"][0], -- 1.7.10.4