X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=projet.py;h=8758a83fa14e19aab6a9027af075941ef797575b;hb=9cd9465271cb7dae51c38210bc2fcb81ed4b771e;hp=ee0c65c1a28509af657b18b853f9f9c02e0b1851;hpb=f1a852664f8bbf18f24f36d5b851d1da7d0cfe38;p=OpenERP%2Fcmmi.git diff --git a/projet.py b/projet.py index ee0c65c..8758a83 100644 --- a/projet.py +++ b/projet.py @@ -4,186 +4,135 @@ from openerp.osv import osv, fields + class Projet(osv.Model): - _name = "projet.projet" + + _name = "cmmi.projet" + + _domains = { + 'moe': [('role_mo_id.type_mo', '=', "MOE")], + 'moa': [('role_mo_id.type_mo', '=', "MOA")], + } _columns = { "name": fields.char(string="Title", size=64, required=True), "description": fields.text(string="Description"), - "domaines": fields.many2many("projet.domaine", - "projet_projet_domaine_rel", - "projets", - string="Domaines"), - "structures": fields.many2many("projet.structure", - "projet_projet_structure_rel", - "projets", + "domaines": fields.one2many("cmmi.projet.domaine", + "project_id", + string="Domaines"), + "structures": fields.many2many("cmmi.mo.structure", string="Structures"), - "team_members": fields.many2many("projet.teammember", - "projet_projet_teammember_rel", - "projets", + "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", + "partner_id", string="Team Members"), - "modules": fields.one2many("projet.module", + "modules": fields.one2many("cmmi.description.module", "projet_id", string="Modules"), - "chantiers": fields.one2many("projet.chantier", + "chantiers": fields.one2many("cmmi.axes.chantier", "projet_id", string="Chantiers"), - "paliers": fields.one2many("projet.palier", + "paliers": fields.one2many("cmmi.axes.palier", "projet_id", string="Paliers"), - "moe_id": fields.many2one("projet.moe", string="MoEs", required=True), - "moa_id": fields.many2one("projet.moa", string="MoAs", required=True), - } - - -class Evolution(osv.Model): - _name = "projet.evolution" - - _columns = { - "name": fields.char(string="Title", size=64, required=True), - "description": fields.text(string="Description"), - } - - -class Structure(osv.Model): - _name = "projet.structure" - - _columns = { - "name": fields.char(string="Title", size=64, required=True), - "description": fields.text(string="Description"), - "projets": fields.many2many("projet.projet", - "projet_projet_structure_rel", - "structures", - string="Projets (structure)") + "phases": fields.one2many("cmmi.phase", + "projet_id", + string="Phases"), + "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", + string="Domaine principal"), + "main_structure": fields.many2one("cmmi.mo.structure", + string="Structure principale"), } + def action_add_domain(self, cr, uid, ids, context=None): + pass -class Module(osv.Model): - _name = "projet.module" - - _columns = { - "name": fields.char(string="Title", size=64, required=True), - "description": fields.text(string="Description"), - "projet_id": fields.many2one("projet.projet", - string="Projet (module)", - required=True), - } - - -class Domaine(osv.Model): - _name = "projet.domaine" - - _columns = { - "name": fields.char(string="Title", size=64, required=True), - "description": fields.text(string="Description"), - "parent_id": fields.many2one("projet.domaine", string="Parent_id"), - "projets": fields.many2many("projet.projet", - "projet_projet_structure_rel", - "domaines", - string="Projets"), - } +class ProjetDomaine(osv.Model): + _name = "cmmi.projet.domaine" -class Teammember(osv.Model): - _name = "projet.teammember" - - _inherit = "res.partner" + def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None): + if isinstance(ids, (int, long)): + ids = [ids] + #return {i: r.domaine_id.name for i, r in + # zip(ids, self.browse(cr, uid, ids, context=context))} + return dict([(i, r.domaine_id.name) for i, r in + zip(ids, self.browse(cr, uid, ids, context=context))]) _columns = { - "projets": fields.many2many("projet.projet", - "projet_projet_teammember_rel", - "team_members", - string="Projets"), - "charges": fields.one2many("projet.projet", - "team_members", - string="Charges"), + "name": fields.function(_get_name, + type='char', + store=True, + string="Nom du domaine"), + "main": fields.boolean(string="Domaine principal ?"), + "project_id": fields.many2one("cmmi.projet", + string="Projet"), + "domaine_id": fields.many2one("cmmi.description.domaine", + string="Domaine"), } - -#TODO trouver un nom a cette chose -class qqch(osv.Model): - _name = "projet.qqch" + def onchange_main(self, cr, uid, ids, project, domaine, main, context=None): + if not main: + return {'value': {'main': True}, + 'warning': { + 'title' : "Integrity Warning", + 'message' : "One of the domains should be the main domain", + } + } + ids = self.search( + cr, + uid, + [ + ('project_id', '=', project), + ('domaine_id', '!=', domaine), + ], + context=context, + ) + current_id = self.search( + cr, + uid, + [ + ('project_id', '=', project), + ('domaine_id', '=', domaine), + ], + context=context, + ) + self.write(cr, uid, ids, {'main': False}, context=context) + self.write(cr, uid, current_id, {'main': True}, context=context) + + return {'value': {'main': True}} + + + +class ProjetMoe(osv.Model): + _name = "cmmi.projet.moe" + + def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None): + if isinstance(ids, (int, long)): + ids = [ids] + return dict([(i, r.domaine_id.name) for i, r in + zip(ids, self.browse(cr, uid, ids, context=context))]) _columns = { - "name": fields.char(string="Title", size=64, required=True), - "description": fields.text(string="Description"), - "date_jalon": fields.date(sring="Jalon"), - "date_init_deb": fields.date(sring="Date initiale début"), - "date_init_fin": fields.date(sring="Date initiale de fin"), - "date_plan_deb": fields.date(string="Date plannifiée début"), - "date_plan_fin": fields.date(string="Date plannifiée de fin"), - "date_reel_deb": fields.date(string="Data réelle début"), - "date_reel_fin": fields.date(string="Data réelle fin"), - } - - -class Chantier(osv.Model): - _name = "projet.chantier" - - _inherit = "projet.qqch" - - _columns = { - "projet_id": fields.many2one("projet.projet", - string="Projet", - required=True), - } - - -class Palier(osv.Model): - _name = "projet.palier" - - _inherit = "projet.qqch" - - _columns = { - "projet_id": fields.many2one("projet.projet", - string="Projet", - required=True), - } - - -class Charge(osv.Model): - _name = "projet.charge" - - _columns = { - "name": fields.char(string="Title", size=64, required=True), - "description": fields.text(string="Description"), - "teammember_id": fields.many2one("projet.teammember", - string="Team Member", - required=True), - } - -class mo(osv.Model): - _name = "projet.mo" - - _choses = [("primaire", "Primaire"), ("secondaire", "Secondaire"), ("generique", "Générique")] - - _columns = { - "name": fields.char(string="Title"), - "description": fields.text(string="Description"), - "chose": fields.selection(_choses, string="Chose", required=True), - } - - _defaults = { - "chose": "generique"} - - -class moe(osv.Model): - _name = "projet.moe" - _inherit = "projet.mo" - - _columns = { - "projets": fields.one2many("projet.projet", - "moe_id", - string="MoE"), - } - - -class moa(osv.Model): - _name= "projet.moa" - _inherit = "projet.mo" - - _columns = { - "projets": fields.one2many("projet.projet", - "moa_id", - string="MoA"), - } + "name": fields.function(_get_name, + type='char', + store=True, + string="Nom de la MOE"), + "main": fields.boolean(string="MOE principale ?"), + "project_id": fields.many2one("cmmi.projet", + string="Projet"), + "moe_id": fields.many2one("cmmi.mo.moe", + string="MOE"), + } \ No newline at end of file