Séparation Phase
[OpenERP/cmmi.git] / projet.py
1 #-*- coding: utf8 -*-
2 '''
3 '''
4
5 from openerp.osv import osv, fields
6
7 class Projet(osv.Model):
8
9     _name = "projet.projet"
10
11     _columns = {
12         "name": fields.char(string="Title", size=64, required=True),
13         "description": fields.text(string="Description"),
14         "domaines": fields.many2many("projet.domaine",
15                                      "projet_projet_domaine_rel",
16                                      "projets",
17                                      string="Domaines"),
18         "structures": fields.many2many("projet.structure",
19                                        "projet_projet_structure_rel",
20                                        "projets",
21                                        string="Structures"),
22         "structures_moe": fields.many2many("projet.structure",
23                                            "projet_projet_structure_rel",
24                                            "projets",
25                                            string="Structures",
26                                            domain=[('role_mo_id.type_mo', '=', "MOE")]),
27         "structures_moa": fields.many2many("projet.structure",
28                                            "projet_projet_structure_rel",
29                                            "projets",
30                                            string="Structures",
31                                            domain=[('role_mo_id.type_mo', '=', "MOA")]),
32         "team_members": fields.many2many("projet.teammember",
33                                          "projet_projet_teammember_rel",
34                                          "projets",
35                                          string="Team Members"),
36         "modules": fields.one2many("projet.module",
37                                    "projet_id",
38                                    string="Modules"),
39         "chantiers": fields.one2many("projet.chantier",
40                                      "projet_id",
41                                      string="Chantiers"),
42         "paliers": fields.one2many("projet.palier",
43                                    "projet_id",
44                                    string="Paliers"),
45         "phases": fields.one2many("projet.phase",
46                                    "projet_id",
47                                    string="Phases"),
48         "evolutions":fields.one2many("projet.evolution",
49                                      "projet_id",
50                                      string="Evolutions"),
51         "moe_id": fields.many2one("projet.moe", string="MoE", required=True),
52         "moa_id": fields.many2one("projet.moa", string="MoA", required=True),
53         "main_domain": fields.many2one("projet.domaine",
54                                        string="Domaine principal"),
55         "main_structure": fields.many2one("projet.structure",
56                                           string="Structure principale"),
57     }
58
59
60 class Evolution(osv.Model):
61     _name = "projet.evolution"
62
63     _priorites = [("incontournable", "Incontournable"),
64                   ("necessaire", "Nécéssaire"),
65                   ("utile", "Utile")]
66
67     _statuts = [("cree", "Crée"), ("encours", "En cours"),
68                 ("termine", "Terminé"), ("abandonne", "Abandonné"),
69                 ("suspendu", "Suspendu")]
70
71     _columns = {
72         "pid": fields.integer(string="PID"),
73         "name": fields.char(string="Title", size=64, required=True),
74         "description": fields.text(string="Description"),
75         "objectif": fields.text(string="Objectif"),
76         "commentaire": fields.text(string="Commentaire"),
77         "keywords": fields.text(string="Mots clés"),
78         "priorite": fields.selection(_priorites, string="Priorité"),
79         "statut": fields.selection(_statuts, string="Statut"),
80         "charges": fields.one2many("projet.charge",
81                                    "evolution_id",
82                                    string="Charges"),
83         "module_id": fields.many2one("projet.module",
84                                      string="Modules"),
85         "chantier_id": fields.many2one("projet.chantier",
86                                     string="Chantier"),
87         "palier_id": fields.many2one("projet.palier",
88                                      string="Palier"),
89         "phase_id": fields.many2one("projet.phase",
90                                     string="Phase"),
91         "projet_id": fields.many2one("projet.projet",
92                                      string="Projet"),
93     }
94
95
96 class Structure(osv.Model):
97
98     _name = "projet.structure"
99
100     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
101
102     _columns = {
103         "name": fields.char(string="Title", size=64, required=True),
104         "code": fields.char(string="Code", size=8, required=True),
105         "description": fields.text(string="Description"),
106         "parent_id": fields.many2one("projet.structure", string="Parent_id"),
107         "statut": fields.selection(_statuts, string="Statut"),
108         "role_mo_id":fields.many2one("projet.role_mo", string="Role MO"),
109         "projets": fields.many2many("projet.projet",
110                                     "projet_projet_structure_rel",
111                                     "structures",
112                                     string="Projets"),
113     }
114
115
116 class Module(osv.Model):
117     _name = "projet.module"
118
119     _columns = {
120         "name": fields.char(string="Title", size=64, required=True),
121         "description": fields.text(string="Description"),
122         "projet_id": fields.many2one("projet.projet",
123                                      string="Projet",
124                                      required=True),
125         "evolutions": fields.one2many("projet.evolution",
126                                       "module_id",
127                                       string="Evolutions")
128     }
129
130
131 class Domaine(osv.Model):
132     _name = "projet.domaine"
133
134     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
135
136     _columns = {
137         "name": fields.char(string="Title", size=64, required=True),
138         "code": fields.char(string="Code", size=8),
139         "description": fields.text(string="Description"),
140         "ordre": fields.integer(string="Ordre"),
141         "parent_id": fields.many2one("projet.domaine", string="Parent_id"),
142         "statut": fields.selection(_statuts, string="Statut"),
143         "projets": fields.many2many("projet.projet",
144                                     "projet_projet_structure_rel",
145                                     "domaines",
146                                     string="Projets"),
147     }
148
149     _order = "id"
150
151
152 class Teammember(osv.Model):
153     _name = "projet.teammember"
154
155     _inherit = "res.partner"
156
157     _columns = {
158         "projets": fields.many2many("projet.projet",
159                                     "projet_projet_teammember_rel",
160                                     "team_members",
161                                     string="Projets"),
162         "charges": fields.one2many("projet.projet",
163                                    "team_members",
164                                    string="Charges"),
165     }
166
167
168 class Charge(osv.Model):
169     _name = "projet.charge"
170
171     _columns = {
172         "name": fields.char(string="Title", size=64, required=True),
173         "description": fields.text(string="Description"),
174         "teammember_id": fields.many2one("projet.teammember",
175                                          string="Team Member",
176                                          required=True),
177         "phase_id": fields.many2one("projet.phase",
178                                     string="Phase",
179                                     required=True),
180         "evolution_id": fields.many2one("projet.evolution",
181                                     string="Evolution",
182                                     required=True),
183         "mo_id": fields.many2one("projet.mo",
184                                  string="Mo"),
185     }