_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",
"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):
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)):
required=True),
}
+ def onchange_main(self, cr, uid, ids, project, moa, main, context=None):
+ pass
+
class ProjetPhase(osv.Model):
_name = "cmmi.projet.phase"