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=ac740e857b6773a5660f18f1eb0707bed957c2c3;p=OpenERP%2Fcmmi.git Merge branch 'master' of ssh://inspyration.org/~/OpenERP/cmmi --- diff --git a/demo/projet.xml b/demo/projet.xml index a1da023..b9d1752 100644 --- a/demo/projet.xml +++ b/demo/projet.xml @@ -25,9 +25,9 @@ Projet of the doom - Ici c'est la description de ce super projet ! + Ici c'est la description de ce super projet ! diff --git a/projet.py b/projet.py index 98e9dfa..d2b26b9 100644 --- a/projet.py +++ b/projet.py @@ -9,25 +9,31 @@ class Projet(osv.Model): _name = "cmmi.projet" - _domains = { - 'moe': [('role_mo_id.type_mo', '=', "MOE")], - 'moa': [('role_mo_id.type_mo', '=', "MOA")], - } + def _get_main_domain(self, cr, uid, ids, field_name=None, arg=None, context=None): + if type(ids) in (int, float): + ids = [ids] + + projects = self.browse(cr, uid, ids, context=context) + + result = {} + + for project in projects: + for domain in project.domains: + if domain.main: + result[project.id] = domain.name + break + else: + result[project.id] = "Any domain is selected as main domain yet" + + return result + _columns = { "name": fields.char(string="Title", size=64, required=True), "description": fields.text(string="Description"), - "domaines": fields.one2many("cmmi.projet.domaine", + "domains": fields.one2many("cmmi.projet.domaine", "project_id", string="Domaines"), - "structures": fields.many2many("cmmi.mo.structure", - string="Structures"), - "structures_moe": fields.many2many("cmmi.mo.structure", - string="Structures", - domain=_domains['moe']), - "structures_moa": fields.many2many("cmmi.mo.structure", - string="Structures", - domain=_domains['moa']), "team_members": fields.many2many("cmmi.partner.teammember", "cmmi_projet_teammember_rel", "projet_id", @@ -48,12 +54,23 @@ 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): @@ -168,9 +185,12 @@ class ProjetMoe(osv.Model): 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)): @@ -192,6 +212,9 @@ class ProjetMoa(osv.Model): required=True), } + def onchange_main(self, cr, uid, ids, project, moa, main, context=None): + pass + class ProjetPhase(osv.Model): _name = "cmmi.projet.phase" diff --git a/views/projet.xml b/views/projet.xml index 1c282a3..bd1199a 100644 --- a/views/projet.xml +++ b/views/projet.xml @@ -14,32 +14,33 @@ - + -

MOE

- - +

MOE

+