Ajout d'un champ charge_reel dans palier
[OpenERP/cmmi.git] / projet.py
index 1c2fc93..f37b957 100644 (file)
--- a/projet.py
+++ b/projet.py
@@ -5,6 +5,7 @@
 from openerp.osv import osv, fields
 
 
+# ================================== PROJET ================================= #
 class Projet(osv.Model):
 
     _name = "cmmi.projet"
@@ -82,6 +83,9 @@ class Projet(osv.Model):
     _columns = {
         "name": fields.char(string="Title", size=64, required=True),
         "description": fields.text(string="Description"),
+        "use_chantier": fields.boolean(string="Utilisation de la notion de chantier ?"),
+        "use_palier": fields.boolean(string="Utilisation de la notion de palier ?"),
+
         # Backrefs
         "domains": fields.one2many("cmmi.projet.domaine",
                                     "project_id",
@@ -127,6 +131,11 @@ class Projet(osv.Model):
                                                 string="Phases sélectionnées"),
     }
 
+    _defaults = {
+        "use_chantier": True,
+        "use_palier": True,
+    }
+
 
     def create(self, cr, uid, vals, context=None):
         project_id = osv.Model.create(self, cr, uid, vals, context=context)
@@ -162,6 +171,7 @@ class Projet(osv.Model):
 
 
 
+# ============================= PROJET DOMAINE ============================== #
 class ProjetDomaine(osv.Model):
 
     _name = "cmmi.projet.domaine"
@@ -221,6 +231,7 @@ class ProjetDomaine(osv.Model):
 
 
 
+# =============================== PROJET MOE ================================ #
 class ProjetMoe(osv.Model):
     _name = "cmmi.projet.moe"
 
@@ -279,6 +290,7 @@ class ProjetMoe(osv.Model):
 
 
 
+# =============================== PROJET MOA ================================ #
 class ProjetMoa(osv.Model):
     _name = "cmmi.projet.moa"
 
@@ -337,21 +349,18 @@ class ProjetMoa(osv.Model):
 
 
 
+# =============================== PROJET PHASE ============================== #
 class ProjetPhase(osv.Model):
     _name = "cmmi.projet.phase"
 
     _description = "Rattachement des Phases aux projets"
 
-    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,
+        "name": fields.related("phase_id",
+                                "name",
+                                read_only=True,
+                                type="char",
+                                relation="cmmi.phase",
                                 string="Nom de la phase"),
         "phase_id": fields.many2one("cmmi.phase",
                                     string="Phase",
@@ -364,6 +373,7 @@ class ProjetPhase(osv.Model):
 
 
 
+# ============================ PROJET TEAM MEMBER =========================== #
 class ProjetTeammember(osv.Model):
     _name = "cmmi.projet.teammember"