View form Mesurable : déplacement du 'State' dans le header
[OpenERP/cmmi.git] / projet.py
index 80ba871..1c2fc93 100644 (file)
--- a/projet.py
+++ b/projet.py
@@ -9,6 +9,8 @@ class Projet(osv.Model):
 
     _name = "cmmi.projet"
 
+    _description = "Table des projets."
+
     def _get_main_domain(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if type(ids) in (int, float):
             ids = [ids]
@@ -62,16 +64,34 @@ class Projet(osv.Model):
                     break
             else:
                 result[project.id] = "Any MOE is selected as main MOE yet"
+        return result
 
+
+    def _get_phases_selectionnees(self, cr, uid, ids, field_name=None, arg=None, context=None):
+        result = {}
+        for projet in self.browse(cr, uid, ids, context=context):
+            res = []
+            for phase in projet.phases:
+                #import pdb; pdb.set_trace()
+                if phase.selectionne:
+                    res.append(phase.id)
+            result[projet.id] = res
         return result
 
 
     _columns = {
         "name": fields.char(string="Title", size=64, required=True),
         "description": fields.text(string="Description"),
+        # Backrefs
         "domains": fields.one2many("cmmi.projet.domaine",
                                     "project_id",
                                     string="Domaines"),
+        "moe_ids": fields.one2many("cmmi.projet.moe",
+                                   "project_id",
+                                   string="MOEs"),
+        "moa_ids": fields.one2many("cmmi.projet.moa",
+                                   "project_id",
+                                   string="MOAs"),
         "team_members": fields.one2many("cmmi.projet.teammember",
                                          "projet_id",
                                          string="Team Members"),
@@ -90,12 +110,8 @@ class Projet(osv.Model):
         "evolutions": fields.one2many("cmmi.evolution",
                                       "projet_id",
                                       string="Evolutions"),
-        "moe_ids": fields.one2many("cmmi.projet.moe",
-                                   "project_id",
-                                   string="MOEs"),
-        "moa_ids": fields.one2many("cmmi.projet.moa",
-                                   "project_id",
-                                   string="MOAs"),
+
+        # Champs fonction rapatriant les mo ou domaine principaux
         "moe_id": fields.function(_get_main_moe,
                                   type="string",
                                   string="MOE principale"),
@@ -105,6 +121,10 @@ class Projet(osv.Model):
         "main_domain": fields.function(_get_main_domain,
                                        type="string",
                                        string="Domaine principal"),
+        "phases_selectionnees": fields.function(_get_phases_selectionnees,
+                                                type="one2many",
+                                                obj="cmmi.projet.phase",
+                                                string="Phases sélectionnées"),
     }
 
 
@@ -112,7 +132,7 @@ class Projet(osv.Model):
         project_id = osv.Model.create(self, cr, uid, vals, context=context)
 
         # Récupération des ids de toutes les phases
-        phase_model = self.pool.get("cmmi.phase.type")
+        phase_model = self.pool.get("cmmi.phase")
         phases_ids = phase_model.search(cr, uid, [])
 
         # Création des relations
@@ -140,10 +160,14 @@ class Projet(osv.Model):
     def action_add_moa(self, cr, uid, ids, context=None):
         pass
 
+
+
 class ProjetDomaine(osv.Model):
 
     _name = "cmmi.projet.domaine"
 
+    _description = "Rattachement des domaines a un projet."
+
     def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if isinstance(ids, (int, long)):
             ids = [ids]
@@ -200,6 +224,8 @@ class ProjetDomaine(osv.Model):
 class ProjetMoe(osv.Model):
     _name = "cmmi.projet.moe"
 
+    _description = "Rattachement des MOEs au projet."
+
     def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if isinstance(ids, (int, long)):
             ids = [ids]
@@ -252,9 +278,12 @@ class ProjetMoe(osv.Model):
         return {'value': {'main': True}}
 
 
+
 class ProjetMoa(osv.Model):
     _name = "cmmi.projet.moa"
 
+    _description = "Rattachement des MOAs a une projet."
+
     def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if isinstance(ids, (int, long)):
             ids = [ids]
@@ -307,6 +336,7 @@ class ProjetMoa(osv.Model):
         return {'value': {'main': True}}
 
 
+
 class ProjetPhase(osv.Model):
     _name = "cmmi.projet.phase"
 
@@ -333,9 +363,12 @@ class ProjetPhase(osv.Model):
     }
 
 
+
 class ProjetTeammember(osv.Model):
     _name = "cmmi.projet.teammember"
 
+    _description = "Rattachement des Team members a un projet."
+
     def _get_partner_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if isinstance(ids, (int, long)):
             ids = [ids]
@@ -366,4 +399,4 @@ class ProjetTeammember(osv.Model):
         "partner_id": fields.many2one("res.partner",
                                     string="Team Member",
                                     required=True),
-    }
\ No newline at end of file
+    }