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/?p=OpenERP%2Fcmmi.git;a=commitdiff_plain;h=682e7d5e5f605d293f2e42c609f5dfc675bbe6e0 Merge branch 'master' of ssh://inspyration.org/~/OpenERP/cmmi --- 682e7d5e5f605d293f2e42c609f5dfc675bbe6e0 diff --cc projet.py index 98e9dfa,8967371..d2b26b9 --- a/projet.py +++ b/projet.py @@@ -48,37 -54,25 +54,48 @@@ class Projet(osv.Model) "evolutions": fields.one2many("cmmi.evolution", "projet_id", string="Evolutions"), - "moe_id": fields.many2one("cmmi.mo.moe", string="MoE", required=True), - "moa_id": fields.many2one("cmmi.mo.moa", string="MoA", required=True), - "main_domain": fields.many2one("cmmi.description.domaine", + "moe_ids": fields.one2many("cmmi.projet.moe", + "project_id", + string="MOEs"), + "moa_ids": fields.one2many("cmmi.projet.moa", + "project_id", + string="MOAs"), + "moe_id": fields.one2many("cmmi.projet.moe", + "project_id", + string="MOE principale", + domaine=[('main', '=', True)]), + "moa_id": fields.one2many("cmmi.projet.moa", + "project_id", + string="MOA principale", + domaine=[('main', '=', True)]), + "main_domain": fields.function(_get_main_domain, + type="string", string="Domaine principal"), - "main_structure": fields.many2one("cmmi.mo.structure", - 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 @@@ -161,16 -155,17 +178,19 @@@ 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): + pass + class ProjetMoa(osv.Model): - _name = "cmmi.projet.moe" + _name = "cmmi.projet.moa" def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None): if isinstance(ids, (int, long)): @@@ -185,13 -180,14 +205,16 @@@ 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): + pass + class ProjetPhase(osv.Model): _name = "cmmi.projet.phase"