Modifs sur projet
[OpenERP/cmmi.git] / projet.py
1 #-*- coding: utf8 -*-
2 '''
3 '''
4
5 from openerp.osv import osv, fields
6 from gtk import TRUE
7
8 class Projet(osv.Model):
9
10     _name = "projet.projet"
11
12     _columns = {
13         "name": fields.char(string="Title", size=64, required=True),
14         "description": fields.text(string="Description"),
15         "domaines": fields.many2many("projet.domaine",
16                                      "projet_projet_domaine_rel",
17                                      "projets",
18                                      string="Domaines"),
19         "structures": fields.many2many("projet.structure",
20                                        "projet_projet_structure_rel",
21                                        "projets",
22                                        string="Structures"),
23         "structures_moe": fields.many2many("projet.structure",
24                                            "projet_projet_structure_rel",
25                                            "projets",
26                                            string="Structures",
27                                            domain=[('role_mo_id.type_mo', '=', "MOE")]),
28         "structures_moa": fields.many2many("projet.structure",
29                                            "projet_projet_structure_rel",
30                                            "projets",
31                                            string="Structures",
32                                            domain=[('role_mo_id.type_mo', '=', "MOA")]),
33         "team_members": fields.many2many("projet.teammember",
34                                          "projet_projet_teammember_rel",
35                                          "projets",
36                                          string="Team Members"),
37         "modules": fields.one2many("projet.module",
38                                    "projet_id",
39                                    string="Modules"),
40         "chantiers": fields.one2many("projet.chantier",
41                                      "projet_id",
42                                      string="Chantiers"),
43         "paliers": fields.one2many("projet.palier",
44                                    "projet_id",
45                                    string="Paliers"),
46         "phases": fields.one2many("projet.phase",
47                                    "projet_id",
48                                    string="Phases"),
49         "evolutions":fields.one2many("projet.evolution",
50                                      "projet_id",
51                                      string="Evolutions"),
52         "moe_id": fields.many2one("projet.moe", string="MoE", required=True),
53         "moa_id": fields.many2one("projet.moa", string="MoA", required=True),
54     }
55
56
57 class Evolution(osv.Model):
58     _name = "projet.evolution"
59
60     _priorites = [("incontournable", "Incontournable"),
61                   ("necessaire", "Nécéssaire"),
62                   ("utile", "Utile")]
63
64     _statuts = [("cree", "Crée"), ("encours", "En cours"),
65                 ("termine", "Terminé"), ("abandonne", "Abandonné"),
66                 ("suspendu", "Suspendu")]
67
68     _columns = {
69         "pid": fields.integer(string="PID"),
70         "name": fields.char(string="Title", size=64, required=True),
71         "description": fields.text(string="Description"),
72         "objectif": fields.text(string="Objectif"),
73         "commentaire": fields.text(string="Commentaire"),
74         "keywords": fields.text(string="Mots clés"),
75         "priorite": fields.selection(_priorites, string="Priorité"),
76         "statut": fields.selection(_statuts, string="Statut"),
77         "charges": fields.one2many("projet.charge",
78                                    "evolution_id",
79                                    string="Charges"),
80         "module_id": fields.many2one("projet.module",
81                                      string="Modules"),
82         "chantier_id": fields.many2one("projet.chantier",
83                                     string="Chantier"),
84         "palier_id": fields.many2one("projet.palier",
85                                      string="Palier"),
86         "phase_id": fields.many2one("projet.phase",
87                                     string="Phase"),
88         "projet_id": fields.many2one("projet.projet",
89                                      string="Projet"),
90     }
91
92
93 class Structure(osv.Model):
94
95     _name = "projet.structure"
96
97     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
98
99     _columns = {
100         "name": fields.char(string="Title", size=64, required=True),
101         "code": fields.char(string="Code", size=8, required=True),
102         "description": fields.text(string="Description"),
103         "parent_id": fields.many2one("projet.structure", string="Parent_id"),
104         "statut": fields.selection(_statuts, string="Statut"),
105         "role_mo_id":fields.many2one("projet.role_mo", string="Role MO"),
106         "projets": fields.many2many("projet.projet",
107                                     "projet_projet_structure_rel",
108                                     "structures",
109                                     string="Projets"),
110     }
111
112
113 class Role_MO(osv.Model):
114     _name = "projet.role_mo"
115
116     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
117
118     _types_mo = [("MOE", "MOE"), ("MOA", "MOA")]
119
120     _columns = {
121         "name": fields.char(string="Title", size=64, required=True),
122         "code": fields.char(string="Code", size=8, required=True),
123         "description": fields.text(string="Description"),
124         "statut": fields.selection(_statuts, string="Statut"),
125         "type_mo": fields.selection(_types_mo, string="Type de MO", required=True),
126         "structures": fields.one2many("projet.structure",
127                                    "role_mo_id",
128                                    string="MOs"),
129         "mo_ids": fields.one2many("projet.mo",
130                                    "role_mo_id",
131                                    string="MOs"),
132     }
133
134 class Module(osv.Model):
135     _name = "projet.module"
136
137     _columns = {
138         "name": fields.char(string="Title", size=64, required=True),
139         "description": fields.text(string="Description"),
140         "projet_id": fields.many2one("projet.projet",
141                                      string="Projet",
142                                      required=True),
143         "evolutions": fields.one2many("projet.evolution",
144                                       "module_id",
145                                       string="Evolutions")
146     }
147
148
149 class Domaine(osv.Model):
150     _name = "projet.domaine"
151
152     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
153
154     _columns = {
155         "name": fields.char(string="Title", size=64, required=True),
156         "code": fields.char(string="Code", size=8),
157         "description": fields.text(string="Description"),
158         "ordre": fields.integer(string="Ordre"),
159         "parent_id": fields.many2one("projet.domaine", string="Parent_id"),
160         "statut": fields.selection(_statuts, string="Statut"),
161         "projets": fields.many2many("projet.projet",
162                                     "projet_projet_structure_rel",
163                                     "domaines",
164                                     string="Projets"),
165     }
166
167
168 class Teammember(osv.Model):
169     _name = "projet.teammember"
170
171     _inherit = "res.partner"
172
173     _columns = {
174         "projets": fields.many2many("projet.projet",
175                                     "projet_projet_teammember_rel",
176                                     "team_members",
177                                     string="Projets"),
178         "charges": fields.one2many("projet.projet",
179                                    "team_members",
180                                    string="Charges"),
181     }
182
183
184 class Type_Phase(osv.Model):
185     _name = "projet.type_phase"
186
187     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
188
189     _columns = {
190         "name": fields.char(string="Title", size=64, required=True),
191         "description": fields.text(string="Description"),
192         "statut": fields.selection(_statuts, string="Statut"),
193     }
194
195
196 class Phase(osv.Model):
197     _name = "projet.phase"
198
199     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
200
201
202     _columns = {
203         "name": fields.char(string="Title", size=64, required=True),
204         "description": fields.text(string="Description"),
205         "statut": fields.selection(_statuts, string="Statut"),
206         "type_phase_id": fields.many2one("projet.type_phase",
207                                          string="Type phase"),
208         "projet_id": fields.many2one("projet.projet",
209                                      string="Projet",
210                                      required=True),
211         "charges": fields.one2many("projet.charge",
212                                    "phase_id",
213                                    string="Charges"),
214         "evolutions": fields.one2many("projet.evolution",
215                                       "phase_id",
216                                       string="Evolutions"),
217         "palier_id": fields.many2one("projet.palier",
218                                      string="Palier"),
219     }
220
221 #TODO trouver un nom a cette chose
222 class qqch(osv.Model):
223     _name = "projet.qqch"
224
225     _statuts = [("cree", "Crée"), ("encours", "En cours"),
226                 ("termine", "Terminé"), ("abandonne", "Abandonné"),
227                 ("suspendu", "Suspendu"), ("generique", "Générique")]
228
229     _columns = {
230         "name": fields.char(string="Title", size=64, required=True),
231         "description": fields.text(string="Description"),
232         "commentaire": fields.text(string="Commentaire"),
233         "statut": fields.selection(_statuts, string="Statut"),
234         "version": fields.char(string="Version", size=16),
235         "date_jalon": fields.date(sring="Jalon"),
236         "date_init_deb": fields.date(sring="Date initiale début"),
237         "date_init_fin": fields.date(sring="Date initiale de fin"),
238         "date_plan_deb": fields.date(string="Date plannifiée début"),
239         "date_plan_fin": fields.date(string="Date plannifiée de fin"),
240         "date_reel_deb": fields.date(string="Data réelle début"),
241         "date_reel_fin": fields.date(string="Data réelle fin"),
242     }
243
244     _sql_constraints = [
245         (
246             "date_init_deb_before_date_init_fin",
247             "CHECK(date_init_deb<> date_init_fin)",
248             "The date_init_deb should be previous date_init_fin",
249         ),
250         (
251             "date_plan_deb_before_date_plan_fin",
252             "CHECK(date_plan_deb <> date_plan_fin)",
253             "The date_plan_deb should be previous date_plan_fin",
254         ),
255         (
256             "date_reel_deb_before_date_reel_fin",
257             "CHECK(date_reel_deb<> date_reel_fin)",
258             "The date_reel_deb should be previous date_reel_fin",
259         ),
260     ]
261
262
263 class Chantier(osv.Model):
264     _name = "projet.chantier"
265
266     _inherit = "projet.qqch"
267
268     _columns = {
269         "projet_id": fields.many2one("projet.projet",
270                                      string="Projet",
271                                      required=True),
272         "evolutions": fields.one2many("projet.evolution",
273                                       "chantier_id",
274                                       string="Evolutions"),
275     }
276
277
278 class Palier(osv.Model):
279     _name = "projet.palier"
280
281     _types_palier = [("normal", "Normal"), ("exceptionnel", "Exceptionnel"),
282                      ("correctif", "Correctif"), ("autre", "Autre")]
283
284     _inherit = "projet.qqch"
285
286     _columns = {
287         "type_palier": fields.selection(_types_palier, string="Type"),
288         "projet_id": fields.many2one("projet.projet",
289                                      string="Projet",
290                                      required=True),
291         "evolutions": fields.one2many("projet.evolution",
292                                       "palier_id",
293                                       string="Evolutions"),
294         "phases": fields.one2many("projet.phase",
295                                   "palier_id",
296                                   string="Phases"),
297     }
298
299
300 class Charge(osv.Model):
301     _name = "projet.charge"
302
303     _columns = {
304         "name": fields.char(string="Title", size=64, required=True),
305         "description": fields.text(string="Description"),
306         "teammember_id": fields.many2one("projet.teammember",
307                                          string="Team Member",
308                                          required=True),
309         "phase_id": fields.many2one("projet.phase",
310                                     string="Phase",
311                                     required=True),
312         "evolution_id": fields.many2one("projet.evolution",
313                                     string="Evolution",
314                                     required=True),
315         "mo_id": fields.many2one("projet.mo",
316                                  string="Mo"),
317     }
318
319 class mo(osv.Model):
320     _name = "projet.mo"
321
322     _choses = [("primaire", "Primaire"),
323                ("secondaire", "Secondaire"),
324                ("generique", "Générique")]
325
326     _columns = {
327         "name": fields.char(string="Title"),
328         "description": fields.text(string="Description"),
329         "chose": fields.selection(_choses, string="Chose", required=True),
330         "role_mo_id": fields.many2one("projet.role_mo", string="Role"),
331         "charges": fields.one2many("projet.charge",
332                                    "mo_id",
333                                    string="Charges"),
334     }
335
336     _defaults = {
337         "chose": "generique"}
338
339
340 class moe(osv.Model):
341     _name = "projet.moe"
342     _inherit = "projet.mo"
343
344     _columns = {
345         "projets": fields.one2many("projet.projet",
346                                      "moe_id",
347                                      string="Projets"),
348     }
349
350
351 class moa(osv.Model):
352     _name= "projet.moa"
353     _inherit = "projet.mo"
354
355     _columns = {
356         "projets": fields.one2many("projet.projet",
357                                      "moa_id",
358                                      string="Projets"),
359     }