Wizard Evolution : Ajout d'une fonction pour la selection d'un palier
[OpenERP/cmmi.git] / wizards / evolution.py
1 #-*- coding: utf8 -*-
2 '''
3 '''
4
5 from openerp.osv import osv, fields
6
7 class EvolutionWizard(osv.TransientModel):
8
9     _name = "cmmi.evolution.wizard"
10
11     def default_get(self, cr, uid, fields, context=None):
12         res = osv.TransientModel.default_get(self, cr, uid, fields, context=context)
13         project_id = context.get('project_id', False)
14         if project_id:
15             res['project_id'] = project_id
16         return res
17
18
19     def _palier_selection(self, cr, uid, context=None):
20         palier_model = self.pool.get("cmmi.axes.palier")
21
22         if context is None or not context.has_key("project_id"):
23             return
24
25         palier_ids = palier_model.search(
26             cr,
27             uid,
28             [('projet_id', '=', context["projet_id"])],
29             context=context
30         )
31
32         print [(p["id"], p["name"]) for p in palier_model.read(
33             cr,
34             uid,
35             palier_ids,
36             fields=["id", "name"],
37             context=context
38         )]
39         return [(p["id"], p["name"]) for p in palier_model.read(
40             cr,
41             uid,
42             palier_ids,
43             fields=["id", "name"],
44             context=context
45         )]
46
47
48
49     _columns = {
50         "projet_id": fields.many2one("cmmi.projet",
51                                      string="Projet",
52                                      required=True),
53         "palier_id": fields.selection(_palier_selection,
54                                      string="Palier",
55                                      required=True),
56         "chantier_id": fields.many2one("cmmi.axes.chantier",
57                                        string="Chantier",
58                                        required=True),
59     }