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
+ def _palier_selection(self, cr, uid, context=None):
+ palier_model = self.pool.get("cmmi.axes.palier")
+
+ if context is None or not context.has_key("project_id"):
+ return
+
+ palier_ids = palier_model.search(
+ cr,
+ uid,
+ [('projet_id', '=', context["project_id"])],
+ context=context
+ )
+
+ print [(p["id"], p["name"]) for p in palier_model.read(
+ cr,
+ uid,
+ palier_ids,
+ fields=["id", "name"],
+ context=context
+ )]
+ return [(p["id"], p["name"]) for p in palier_model.read(
+ cr,
+ uid,
+ palier_ids,
+ fields=["id", "name"],
+ context=context
+ )]
+
+
+ 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"],
+ "keywords": res["keywords"],
+ "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.many2one("cmmi.axes.palier",
+ "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),
}