Wizard Evolution : Ajout d'une fonction pour la selection d'un chantier
authorAlicia FLOREZ <alicflorez@gmail.com>
Tue, 11 Jun 2013 16:08:15 +0000 (18:08 +0200)
committerAlicia FLOREZ <alicflorez@gmail.com>
Tue, 11 Jun 2013 16:08:15 +0000 (18:08 +0200)
wizards/evolution.py

index 78c5709..9d52231 100644 (file)
@@ -45,6 +45,35 @@ class EvolutionWizard(osv.TransientModel):
         )]
 
 
+    def _chantier_selection(self, cr, uid, context=None):
+        chantier_model = self.pool.get("cmmi.axes.palier")
+
+        if context is None or not context.has_key("project_id"):
+            return
+
+        chantier_ids = chantier_model.search(
+            cr,
+            uid,
+            [('projet_id', '=', context["projet_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
+        )]
+
+
 
     _columns = {
         "projet_id": fields.many2one("cmmi.projet",
@@ -53,7 +82,7 @@ class EvolutionWizard(osv.TransientModel):
         "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),
     }