Modification vue wizard
[OpenERP/cmmi.git] / wizards / evolution.py
index 78c5709..b901461 100644 (file)
@@ -10,9 +10,9 @@ class EvolutionWizard(osv.TransientModel):
 
     def default_get(self, cr, uid, fields, context=None):
         res = osv.TransientModel.default_get(self, cr, uid, fields, context=context)
-        project_id = context.get('project_id', False)
-        if project_id:
-            res['project_id'] = project_id
+        projet_id = context.get('project_id', False)
+        if projet_id:
+            res['projet_id'] = projet_id
         return res
 
 
@@ -25,7 +25,7 @@ class EvolutionWizard(osv.TransientModel):
         palier_ids = palier_model.search(
             cr,
             uid,
-            [('projet_id', '=', context["projet_id"])],
+            [('projet_id', '=', context["project_id"])],
             context=context
         )
 
@@ -45,15 +45,73 @@ class EvolutionWizard(osv.TransientModel):
         )]
 
 
+    def _chantier_selection(self, cr, uid, context=None):
+        chantier_model = self.pool.get("cmmi.axes.chantier")
+
+        if context is None or not context.has_key("project_id"):
+            return
+
+        chantier_ids = chantier_model.search(
+            cr,
+            uid,
+            [('projet_id', '=', context["project_id"])],
+            context=context
+        )
+
+        print [(c["id"], c["name"]) for c in chantier_model.read(
+            cr,
+            uid,
+            chantier_ids,
+            fields=["id", "name"],
+            context=context
+        )]
+        return [(c["id"], c["name"]) for c in chantier_model.read(
+            cr,
+            uid,
+            chantier_ids,
+            fields=["id", "name"],
+            context=context
+        )]
+
+
+    def action_add_evolution(self, cr, uid, ids, context=None):
+        evolution_model = self.pool.get("cmmi.evolution")
+
+        id = ids[0]
+
+        res = self.read(cr, uid, id, context=context)
+        evolution_model.create(
+            cr,
+            uid,
+            {
+                "name": res["name"],
+                "description": res["description"],
+                "objectif": res["objectif"],
+                "commentaire": res["commentaire"],
+                "palier_id": res["palier_id"],
+                "chantier_id": res["chantier_id"],
+                "projet_id": res["projet_id"][0],
+            },
+            context=context
+        )
+
+        return {'type': 'ir.actions.act_windows_close'}
+
 
     _columns = {
+        "pid": fields.integer(string="PID"),
+        "name": fields.char(string="Title", size=64, required=True),
+        "description": fields.text(string="Description"),
+        "objectif": fields.text(string="Objectif"),
+        "commentaire": fields.text(string="Commentaire"),
+        "keywords": fields.text(string="Mots clés"),
         "projet_id": fields.many2one("cmmi.projet",
                                      string="Projet",
                                      required=True),
         "palier_id": fields.selection(_palier_selection,
                                      string="Palier",
                                      required=True),
-        "chantier_id": fields.many2one("cmmi.axes.chantier",
+        "chantier_id": fields.selection(_chantier_selection,
                                        string="Chantier",
                                        required=True),
     }