From f0d65a817ca70048e0f4b7a4d02248642e66d9c7 Mon Sep 17 00:00:00 2001 From: Alicia FLOREZ Date: Tue, 11 Jun 2013 18:08:15 +0200 Subject: [PATCH] Wizard Evolution : Ajout d'une fonction pour la selection d'un chantier --- wizards/evolution.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/wizards/evolution.py b/wizards/evolution.py index 78c5709..9d52231 100644 --- a/wizards/evolution.py +++ b/wizards/evolution.py @@ -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), } -- 1.7.10.4