From: Alicia FLOREZ Date: Thu, 23 May 2013 15:45:18 +0000 (+0200) Subject: Merge branch 'master' of ssh://inspyration.org/~/OpenERP/cmmi X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=682e7d5e5f605d293f2e42c609f5dfc675bbe6e0;hp=1a62f57084eaea2cfee18ae31bd81451305f2389;p=OpenERP%2Fcmmi.git Merge branch 'master' of ssh://inspyration.org/~/OpenERP/cmmi --- diff --git a/projet.py b/projet.py index 8967371..d2b26b9 100644 --- a/projet.py +++ b/projet.py @@ -73,6 +73,29 @@ class Projet(osv.Model): string="Domaine principal"), } + def create(self, cr, uid, vals, context=None): + project_id = osv.Model.create(self, cr, uid, vals, context=context) + + # Récupération des ids de toutes les phases + phase_model = self.pool.get("cmmi.phase") + phases_ids = phase_model.search(cr, uid, []) + + # Création des relations + projet_phase_model = self.pool.get("cmmi.projet.phase") + for phase_id in phases_ids: + projet_phase_model.create( + cr, + uid, + { + 'projet_id': project_id, + 'phase_id': phase_id, + 'selectionne': False, + } + ) + + return project_id + + def action_add_domain(self, cr, uid, ids, context=None): pass @@ -155,9 +178,11 @@ class ProjetMoe(osv.Model): string="Nom de la MOE"), "main": fields.boolean(string="MOE principale ?"), "project_id": fields.many2one("cmmi.projet", - string="Projet"), + string="Projet", + required=True), "moe_id": fields.many2one("cmmi.mo.moe", - string="MOE"), + string="MOE", + required=True), } def onchange_main(self, cr, uid, ids, project, moe, main, context=None): @@ -180,9 +205,11 @@ class ProjetMoa(osv.Model): string="Nom de la MOA"), "main": fields.boolean(string="MOA principale ?"), "project_id": fields.many2one("cmmi.projet", - string="Projet"), + string="Projet", + required=True), "moa_id": fields.many2one("cmmi.mo.moa", - string="MOA"), + string="MOA", + required=True), } def onchange_main(self, cr, uid, ids, project, moa, main, context=None): @@ -205,7 +232,9 @@ class ProjetPhase(osv.Model): string="Nom de la phase"), "selectionne": fields.boolean(string="Phase sélectionnée ?"), "projet_id": fields.many2one("cmmi.projet", - string="Projet"), + string="Projet", + required=True), "phase_id": fields.many2one("cmmi.phase", - string="Phase"), + string="Phase", + required=True), } \ No newline at end of file