Utilisation de fields.related pour l'affectation du name de la class ProjetPhase
[OpenERP/cmmi.git] / projet.py
index 1c2fc93..e730fef 100644 (file)
--- a/projet.py
+++ b/projet.py
@@ -82,6 +82,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 +130,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)
@@ -342,16 +350,12 @@ class ProjetPhase(osv.Model):
 
     _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",