X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=projet.py;h=12ec84e1609558dec06daa592c85f1c50e8dd1a3;hb=2d45e63b968939401e2c69626b73511124b4f87d;hp=ee0c65c1a28509af657b18b853f9f9c02e0b1851;hpb=af2a17a4273da8149a2de8e7e08f828f26c962c0;p=OpenERP%2Fcmmi.git diff --git a/projet.py b/projet.py index ee0c65c..12ec84e 100644 --- a/projet.py +++ b/projet.py @@ -3,8 +3,10 @@ ''' from openerp.osv import osv, fields +from gtk import TRUE class Projet(osv.Model): + _name = "projet.projet" _columns = { @@ -18,6 +20,16 @@ class Projet(osv.Model): "projet_projet_structure_rel", "projets", string="Structures"), + "structures_moe": fields.many2many("projet.structure", + "projet_projet_structure_rel", + "projets", + string="Structures", + domain=[('role_mo_id.type_mo', '=', "MOE")]), + "structures_moa": fields.many2many("projet.structure", + "projet_projet_structure_rel", + "projets", + string="Structures", + domain=[('role_mo_id.type_mo', '=', "MOA")]), "team_members": fields.many2many("projet.teammember", "projet_projet_teammember_rel", "projets", @@ -31,33 +43,98 @@ class Projet(osv.Model): "paliers": fields.one2many("projet.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), + "phases": fields.one2many("projet.phase", + "projet_id", + string="Phases"), + "evolutions":fields.one2many("projet.evolution", + "projet_id", + string="Evolutions"), + "moe_id": fields.many2one("projet.moe", string="MoE", required=True), + "moa_id": fields.many2one("projet.moa", string="MoA", required=True), + "main_domain": fields.many2one("projet.domaine", + string="Domaine principal"), + "main_structure": fields.many2one("projet.structure", + string="Structure principale"), } class Evolution(osv.Model): _name = "projet.evolution" + _priorites = [("incontournable", "Incontournable"), + ("necessaire", "Nécéssaire"), + ("utile", "Utile")] + + _statuts = [("cree", "Crée"), ("encours", "En cours"), + ("termine", "Terminé"), ("abandonne", "Abandonné"), + ("suspendu", "Suspendu")] + _columns = { + "pid": fields.integer(string="PID"), "name": fields.char(string="Title", size=64, required=True), "description": fields.text(string="Description"), + "objectif": fields.text(string="Objectif"), + "commentaire": fields.text(string="Commentaire"), + "keywords": fields.text(string="Mots clés"), + "priorite": fields.selection(_priorites, string="Priorité"), + "statut": fields.selection(_statuts, string="Statut"), + "charges": fields.one2many("projet.charge", + "evolution_id", + string="Charges"), + "module_id": fields.many2one("projet.module", + string="Modules"), + "chantier_id": fields.many2one("projet.chantier", + string="Chantier"), + "palier_id": fields.many2one("projet.palier", + string="Palier"), + "phase_id": fields.many2one("projet.phase", + string="Phase"), + "projet_id": fields.many2one("projet.projet", + string="Projet"), } class Structure(osv.Model): + _name = "projet.structure" + _statuts = [("actif", "Actif"), ("inactif", "Inactif")] + _columns = { "name": fields.char(string="Title", size=64, required=True), + "code": fields.char(string="Code", size=8, required=True), "description": fields.text(string="Description"), + "parent_id": fields.many2one("projet.structure", string="Parent_id"), + "statut": fields.selection(_statuts, string="Statut"), + "role_mo_id":fields.many2one("projet.role_mo", string="Role MO"), "projets": fields.many2many("projet.projet", "projet_projet_structure_rel", "structures", - string="Projets (structure)") + string="Projets"), } +class Role_MO(osv.Model): + _name = "projet.role_mo" + + _statuts = [("actif", "Actif"), ("inactif", "Inactif")] + + _types_mo = [("MOE", "MOE"), ("MOA", "MOA")] + + _columns = { + "name": fields.char(string="Title", size=64, required=True), + "code": fields.char(string="Code", size=8, required=True), + "description": fields.text(string="Description"), + "statut": fields.selection(_statuts, string="Statut"), + "type_mo": fields.selection(_types_mo, string="Type de MO", required=True), + "structures": fields.one2many("projet.structure", + "role_mo_id", + string="MOs"), + "mo_ids": fields.one2many("projet.mo", + "role_mo_id", + string="MOs"), + } + class Module(osv.Model): _name = "projet.module" @@ -65,18 +142,26 @@ class Module(osv.Model): "name": fields.char(string="Title", size=64, required=True), "description": fields.text(string="Description"), "projet_id": fields.many2one("projet.projet", - string="Projet (module)", + string="Projet", required=True), + "evolutions": fields.one2many("projet.evolution", + "module_id", + string="Evolutions") } class Domaine(osv.Model): _name = "projet.domaine" + _statuts = [("actif", "Actif"), ("inactif", "Inactif")] + _columns = { "name": fields.char(string="Title", size=64, required=True), + "code": fields.char(string="Code", size=8), "description": fields.text(string="Description"), + "ordre": fields.integer(string="Ordre"), "parent_id": fields.many2one("projet.domaine", string="Parent_id"), + "statut": fields.selection(_statuts, string="Statut"), "projets": fields.many2many("projet.projet", "projet_projet_structure_rel", "domaines", @@ -100,13 +185,57 @@ class Teammember(osv.Model): } +class Type_Phase(osv.Model): + _name = "projet.type_phase" + + _statuts = [("actif", "Actif"), ("inactif", "Inactif")] + + _columns = { + "name": fields.char(string="Title", size=64, required=True), + "description": fields.text(string="Description"), + "statut": fields.selection(_statuts, string="Statut"), + } + + +class Phase(osv.Model): + _name = "projet.phase" + + _statuts = [("actif", "Actif"), ("inactif", "Inactif")] + + + _columns = { + "name": fields.char(string="Title", size=64, required=True), + "description": fields.text(string="Description"), + "statut": fields.selection(_statuts, string="Statut"), + "type_phase_id": fields.many2one("projet.type_phase", + string="Type phase"), + "projet_id": fields.many2one("projet.projet", + string="Projet", + required=True), + "charges": fields.one2many("projet.charge", + "phase_id", + string="Charges"), + "evolutions": fields.one2many("projet.evolution", + "phase_id", + string="Evolutions"), + "palier_id": fields.many2one("projet.palier", + string="Palier"), + } + #TODO trouver un nom a cette chose class qqch(osv.Model): _name = "projet.qqch" + _statuts = [("cree", "Crée"), ("encours", "En cours"), + ("termine", "Terminé"), ("abandonne", "Abandonné"), + ("suspendu", "Suspendu"), ("generique", "Générique")] + _columns = { "name": fields.char(string="Title", size=64, required=True), "description": fields.text(string="Description"), + "commentaire": fields.text(string="Commentaire"), + "statut": fields.selection(_statuts, string="Statut"), + "version": fields.char(string="Version", size=16), "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"), @@ -116,6 +245,24 @@ class qqch(osv.Model): "date_reel_fin": fields.date(string="Data réelle fin"), } + _sql_constraints = [ + ( + "date_init_deb_before_date_init_fin", + "CHECK(date_init_deb<> date_init_fin)", + "The date_init_deb should be previous date_init_fin", + ), + ( + "date_plan_deb_before_date_plan_fin", + "CHECK(date_plan_deb <> date_plan_fin)", + "The date_plan_deb should be previous date_plan_fin", + ), + ( + "date_reel_deb_before_date_reel_fin", + "CHECK(date_reel_deb<> date_reel_fin)", + "The date_reel_deb should be previous date_reel_fin", + ), + ] + class Chantier(osv.Model): _name = "projet.chantier" @@ -126,18 +273,31 @@ class Chantier(osv.Model): "projet_id": fields.many2one("projet.projet", string="Projet", required=True), + "evolutions": fields.one2many("projet.evolution", + "chantier_id", + string="Evolutions"), } class Palier(osv.Model): _name = "projet.palier" + _types_palier = [("normal", "Normal"), ("exceptionnel", "Exceptionnel"), + ("correctif", "Correctif"), ("autre", "Autre")] + _inherit = "projet.qqch" _columns = { + "type_palier": fields.selection(_types_palier, string="Type"), "projet_id": fields.many2one("projet.projet", string="Projet", required=True), + "evolutions": fields.one2many("projet.evolution", + "palier_id", + string="Evolutions"), + "phases": fields.one2many("projet.phase", + "palier_id", + string="Phases"), } @@ -150,17 +310,31 @@ class Charge(osv.Model): "teammember_id": fields.many2one("projet.teammember", string="Team Member", required=True), + "phase_id": fields.many2one("projet.phase", + string="Phase", + required=True), + "evolution_id": fields.many2one("projet.evolution", + string="Evolution", + required=True), + "mo_id": fields.many2one("projet.mo", + string="Mo"), } class mo(osv.Model): _name = "projet.mo" - _choses = [("primaire", "Primaire"), ("secondaire", "Secondaire"), ("generique", "Générique")] + _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), + "role_mo_id": fields.many2one("projet.role_mo", string="Role"), + "charges": fields.one2many("projet.charge", + "mo_id", + string="Charges"), } _defaults = { @@ -174,7 +348,7 @@ class moe(osv.Model): _columns = { "projets": fields.one2many("projet.projet", "moe_id", - string="MoE"), + string="Projets"), } @@ -185,5 +359,5 @@ class moa(osv.Model): _columns = { "projets": fields.one2many("projet.projet", "moa_id", - string="MoA"), + string="Projets"), }