From: Alicia FLOREZ Date: Thu, 23 May 2013 15:45:09 +0000 (+0200) Subject: Ajout de création de relations projet/phase lors de la création d'un projet X-Git-Url: http://git.inspyration.org/?p=OpenERP%2Fcmmi.git;a=commitdiff_plain;h=ac740e857b6773a5660f18f1eb0707bed957c2c3 Ajout de création de relations projet/phase lors de la création d'un projet --- diff --git a/projet.py b/projet.py index a939996..98e9dfa 100644 --- a/projet.py +++ b/projet.py @@ -56,6 +56,29 @@ class Projet(osv.Model): string="Structure principale"), } + 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 @@ -139,10 +162,10 @@ class ProjetMoe(osv.Model): "main": fields.boolean(string="MOE principale ?"), "project_id": fields.many2one("cmmi.projet", string="Projet", - required=True), + required=True), "moe_id": fields.many2one("cmmi.mo.moe", - string="MOE", - required=True), + string="MOE", + required=True), } @@ -163,10 +186,10 @@ class ProjetMoa(osv.Model): "main": fields.boolean(string="MOA principale ?"), "project_id": fields.many2one("cmmi.projet", string="Projet", - required=True), + required=True), "moa_id": fields.many2one("cmmi.mo.moa", - string="MOA", - required=True), + string="MOA", + required=True), } @@ -190,5 +213,5 @@ class ProjetPhase(osv.Model): required=True), "phase_id": fields.many2one("cmmi.phase", string="Phase", - required=True), + required=True), } \ No newline at end of file