Corrections sur la vue phase et simplification
[OpenERP/cmmi.git] / evolution.py
index c45b089..8594dd5 100644 (file)
@@ -8,6 +8,10 @@ from openerp.osv import osv, fields
 class Evolution(osv.Model):
     _name = "cmmi.evolution"
 
+    _domains = {
+        'human': [('is_company', '=', "False")],
+    }
+
     _priorites = [("incontournable", "Incontournable"),
                   ("necessaire", "Nécéssaire"),
                   ("utile", "Utile")]
@@ -25,21 +29,56 @@ class Evolution(osv.Model):
         "keywords": fields.text(string="Mots clés"),
         "priorite": fields.selection(_priorites, string="Priorité"),
         "statut": fields.selection(_statuts, string="Statut"),
-        "charges": fields.one2many("projet.charge",
-                                   "evolution_id",
-                                   string="Charges"),
-        "module_id": fields.many2one("projet.module",
+#        "charges": fields.one2many("cmmi.evolution.charge", # Supprimé !
+#                                   "evolution_id",
+#                                   string="Charges"),
+        "module_id": fields.many2one("cmmi.description.module",
                                      string="Modules"),
-        "chantier_id": fields.many2one("projet.chantier",
+        "chantier_id": fields.many2one("cmmi.axes.chantier",
                                        string="Chantier"),
-        "palier_id": fields.many2one("projet.palier",
+        "palier_id": fields.many2one("cmmi.axes.palier",
                                      string="Palier"),
-        "phase_id": fields.many2one("projet.phase",
-                                    string="Phase"),
-        "projet_id": fields.many2one("projet.projet",
+        "projet_id": fields.many2one("cmmi.projet",
                                      string="Projet"),
+        "demandeur": fields.many2one("res.partner",
+                                     string="Demandeur",
+                                     domain=_domains['human']),
+    }
+
+
+class Phase(osv.Model):
+    _name = "cmmi.evolution.phase"
+
+    _description = "Evolution's phase / Phase d'une évolution"
+
+    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.axes.palier.phase",
+                                    string="Phase"),
+        "evolution_id": fields.many2one("cmmi.evolution",
+                                        string="Palier"),
     }
 
+    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 Charge(osv.Model):
     _name = "cmmi.evolution.charge"
@@ -47,15 +86,11 @@ class Charge(osv.Model):
     _columns = {
         "name": fields.char(string="Title", size=64, required=True),
         "description": fields.text(string="Description"),
-        "teammember_id": fields.many2one("projet.teammember",
+        "teammember_id": fields.many2one("res.partner", # TODO: Vers l'association teammember MO plutôt que MO.
                                          string="Team Member",
                                          required=True),
-        "phase_id": fields.many2one("projet.phase",
-                                    string="Phase",
-                                    required=True),
-        "evolution_id": fields.many2one("projet.evolution",
-                                        string="Evolution",
+        "phase_id": fields.many2one("cmmi.evolution.phase",
+                                        string="Phase de l'évolution",
                                         required=True),
-        "mo_id": fields.many2one("projet.mo",
-                                 string="Mo"),
     }
+