X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=projet.py;h=d2b26b9f7557a09c1b24454b0d32f906d0eb8645;hb=682e7d5e5f605d293f2e42c609f5dfc675bbe6e0;hp=98e9dfacb54bbcf1c40512f4dc361db76dca1004;hpb=ac740e857b6773a5660f18f1eb0707bed957c2c3;p=OpenERP%2Fcmmi.git 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"