From a46a0ec4578acecf4ff33a6013a707bc9b7849fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20CHAZALLET?= Date: Thu, 30 May 2013 13:14:46 +0200 Subject: [PATCH] Refonte de la notion de phase 3/3 --- axes.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- phase.py | 22 -------------------- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/axes.py b/axes.py index 3236651..aa6ccf1 100644 --- a/axes.py +++ b/axes.py @@ -130,38 +130,83 @@ class Mesurable(osv.Model): #============================================================================== -class Chantier(osv.Model): - _name = "cmmi.axes.chantier" +class Palier(osv.Model): + _name = "cmmi.axes.palier" + + _description = "Palier d'un projet." _inherit = "cmmi.axes.mesurable" + _types_palier = [("normal", "Normal"), ("exceptionnel", "Exceptionnel"), + ("correctif", "Correctif"), ("autre", "Autre")] + _columns = { + "type_palier": fields.selection(_types_palier, string="Type"), "projet_id": fields.many2one("cmmi.projet", string="Projet", required=True), "evolutions": fields.one2many("cmmi.evolution", - "chantier_id", + "palier_id", string="Evolutions"), + "phases": fields.one2many("cmmi.projet.phase", + "palier_id", + string="Phases"), } -class Palier(osv.Model): - _name = "cmmi.axes.palier" +class Phase(osv.Model): + _name = "cmmi.axes.palier.phase" + + _description = "Step's phase / Phase d'un palier" _inherit = "cmmi.axes.mesurable" - _types_palier = [("normal", "Normal"), ("exceptionnel", "Exceptionnel"), - ("correctif", "Correctif"), ("autre", "Autre")] + def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None): + if isinstance(ids, (int, long)): + ids = [ids] + return dict([(i, r.phase_id.name) for i, r in + zip(ids, self.browse(cr, uid, ids, context=context))]) + + + _columns = { + "name": fields.function(_get_name, + type='char', + store=True, + string="Nom de la phase"), + "phase_id": fields.many2one("cmmi.projet.phase", + string="Type phase"), + "palier_id": fields.many2one("cmmi.axes.palier", + string="Palier"), + # backrefs + "charges": fields.one2many("cmmi.evolution.charge", + "phase_id", + string="Charges"), + "evolutions": fields.one2many("cmmi.evolution", + "phase_id", + string="Evolutions"), + } + + def create(self, cr, uid, vals, context=None): + # TODO: gérer la création d'une phase de palier. + # Vérifier les valeurs contenues dans vals et les modifier / rajouter si nécessaire selon les cas suivants + + # Si description est vide, alors par défaut, recopie de la description du palier et de la phase (concaténés avec un retour à la ligne entre les deux). + # Si commentaire est vide, alors par défaut, recopie du commentaire du palier. + # Si version est vide, alors par dégaut, recopie de la version du palier. + + return osv.Model.create(self, cr, uid, vals, context=context) + + +class Chantier(osv.Model): + _name = "cmmi.axes.chantier" + + _inherit = "cmmi.axes.mesurable" _columns = { - "type_palier": fields.selection(_types_palier, string="Type"), "projet_id": fields.many2one("cmmi.projet", string="Projet", required=True), "evolutions": fields.one2many("cmmi.evolution", - "palier_id", + "chantier_id", string="Evolutions"), - "phases": fields.one2many("cmmi.phase", - "palier_id", - string="Phases"), } diff --git a/phase.py b/phase.py index ba6052f..05940a5 100644 --- a/phase.py +++ b/phase.py @@ -17,25 +17,3 @@ class Phase(osv.Model): "description": fields.text(string="Description"), "statut": fields.selection(_statuts, string="Statut"), } - - -#class Phase(osv.Model): -# _name = "cmmi.phase" -# -# _statuts = [("actif", "Actif"), ("inactif", "Inactif")] -# -# _columns = { -# "name": fields.char(string="Title", size=64, required=True), -# "description": fields.text(string="Description"), -# "statut": fields.selection(_statuts, string="Statut"), -# "type_phase_id": fields.many2one("cmmi.phase.type", -# string="Type phase"), -# "charges": fields.one2many("cmmi.evolution.charge", -# "phase_id", -# string="Charges"), -# "evolutions": fields.one2many("cmmi.evolution", -# "phase_id", -# string="Evolutions"), -# "palier_id": fields.many2one("cmmi.axes.palier", -# string="Palier"), -# } -- 1.7.10.4