Rajout de champs à la classe projet.palier
[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     _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         "team_members": fields.many2many("projet.teammember",
23                                          "projet_projet_teammember_rel",
24                                          "projets",
25                                          string="Team Members"),
26         "modules": fields.one2many("projet.module",
27                                    "projet_id",
28                                    string="Modules"),
29         "chantiers": fields.one2many("projet.chantier",
30                                      "projet_id",
31                                      string="Chantiers"),
32         "paliers": fields.one2many("projet.palier",
33                                    "projet_id",
34                                    string="Paliers"),
35         "phases": fields.one2many("projet.phase",
36                                    "projet_id",
37                                    string="Phases"),
38         "evolutions":fields.one2many("projet.evolution",
39                                      "projet_id",
40                                      string="Evolutions"),
41         "moe_id": fields.many2one("projet.moe", string="MoE", required=True),
42         "moa_id": fields.many2one("projet.moa", string="MoA", required=True),
43     }
44
45
46 class Evolution(osv.Model):
47     _name = "projet.evolution"
48
49     _columns = {
50         "name": fields.char(string="Title", size=64, required=True),
51         "description": fields.text(string="Description"),
52         "charges": fields.one2many("projet.charge",
53                                    "evolution_id",
54                                    string="Charges"),
55         "module_id": fields.many2one("projet.module",
56                                      string="Modules"),
57         "chantier_id": fields.many2one("projet.chantier",
58                                     string="Chantier"),
59         "palier_id": fields.many2one("projet.palier",
60                                      string="Palier"),
61         "phase_id": fields.many2one("projet.phase",
62                                     string="Phase"),
63         "projet_id": fields.many2one("projet.projet",
64                                      string="Projet")
65     }
66
67
68 class Structure(osv.Model):
69     _name = "projet.structure"
70
71     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
72
73     _columns = {
74         "name": fields.char(string="Title", size=64, required=True),
75         "code": fields.char(string="Code", size=8, required=True),
76         "description": fields.text(string="Description"),
77         "parent_id": fields.many2one("projet.structure", string="Parent_id"),
78         "statut": fields.selection(_statuts, string="Statut"),
79         "projets": fields.many2many("projet.projet",
80                                     "projet_projet_structure_rel",
81                                     "structures",
82                                     string="Projets"),
83     }
84
85
86 class Module(osv.Model):
87     _name = "projet.module"
88
89     _columns = {
90         "name": fields.char(string="Title", size=64, required=True),
91         "description": fields.text(string="Description"),
92         "projet_id": fields.many2one("projet.projet",
93                                      string="Projet",
94                                      required=True),
95         "evolutions": fields.one2many("projet.evolution",
96                                       "module_id",
97                                       string="Evolutions")
98     }
99
100
101 class Domaine(osv.Model):
102     _name = "projet.domaine"
103
104     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
105
106     _columns = {
107         "name": fields.char(string="Title", size=64, required=True),
108         "code": fields.char(string="Code", size=8),
109         "description": fields.text(string="Description"),
110         "ordre": fields.integer(string="Ordre"),
111         "parent_id": fields.many2one("projet.domaine", string="Parent_id"),
112         "statut": fields.selection(_statuts, string="Statut"),
113         "projets": fields.many2many("projet.projet",
114                                     "projet_projet_structure_rel",
115                                     "domaines",
116                                     string="Projets"),
117     }
118
119
120 class Teammember(osv.Model):
121     _name = "projet.teammember"
122
123     _inherit = "res.partner"
124
125     _columns = {
126         "projets": fields.many2many("projet.projet",
127                                     "projet_projet_teammember_rel",
128                                     "team_members",
129                                     string="Projets"),
130         "charges": fields.one2many("projet.projet",
131                                    "team_members",
132                                    string="Charges"),
133     }
134
135
136 class Phase(osv.Model):
137     _name = "projet.phase"
138
139     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
140
141
142     _columns = {
143         "name": fields.char(string="Title", size=64, required=True),
144         "description": fields.text(string="Description"),
145         "statut": fields.selection(_statuts, string="Statut"),
146         "projet_id": fields.many2one("projet.projet",
147                                      string="Projet",
148                                      required=True),
149         "charges": fields.one2many("projet.charge",
150                                    "phase_id",
151                                    string="Charges"),
152         "evolutions": fields.one2many("projet.evolution",
153                                       "phase_id",
154                                       string="Evolutions"),
155         "palier_id": fields.many2one("projet.palier",
156                                      string="Palier"),
157     }
158
159 #TODO trouver un nom a cette chose
160 class qqch(osv.Model):
161     _name = "projet.qqch"
162
163     _columns = {
164         "name": fields.char(string="Title", size=64, required=True),
165         "description": fields.text(string="Description"),
166         "date_jalon": fields.date(sring="Jalon"),
167         "date_init_deb": fields.date(sring="Date initiale début"),
168         "date_init_fin": fields.date(sring="Date initiale de fin"),
169         "date_plan_deb": fields.date(string="Date plannifiée début"),
170         "date_plan_fin": fields.date(string="Date plannifiée de fin"),
171         "date_reel_deb": fields.date(string="Data réelle début"),
172         "date_reel_fin": fields.date(string="Data réelle fin"),
173     }
174
175     _sql_constraints = [
176         (
177             "date_init_deb_before_date_init_fin",
178             "CHECK(date_init_deb<> date_init_fin)",
179             "The date_init_deb should be previous date_init_fin",
180         ),
181         (
182             "date_plan_deb_before_date_plan_fin",
183             "CHECK(date_plan_deb <> date_plan_fin)",
184             "The date_plan_deb should be previous date_plan_fin",
185         ),
186         (
187             "date_reel_deb_before_date_reel_fin",
188             "CHECK(date_reel_deb<> date_reel_fin)",
189             "The date_reel_deb should be previous date_reel_fin",
190         ),
191     ]
192
193
194 class Chantier(osv.Model):
195     _name = "projet.chantier"
196
197     _inherit = "projet.qqch"
198
199     _columns = {
200         "projet_id": fields.many2one("projet.projet",
201                                      string="Projet",
202                                      required=True),
203         "evolutions": fields.one2many("projet.evolution",
204                                       "chantier_id",
205                                       string="Evolutions"),
206     }
207
208
209 class Palier(osv.Model):
210     _name = "projet.palier"
211
212     _types_palier = [("normal", "Normal"), ("exceptionnel", "Exceptionnel"), ("correctif", "Correctif"), ("autre", "Autre")]
213
214
215     _inherit = "projet.qqch"
216
217     _columns = {
218         "type_palier": fields.selection(_types_palier, string="Type"),
219         "projet_id": fields.many2one("projet.projet",
220                                      string="Projet",
221                                      required=True),
222         "evolutions": fields.one2many("projet.evolution",
223                                       "palier_id",
224                                       string="Evolutions"),
225         "phases": fields.one2many("projet.phase",
226                                   "palier_id",
227                                   string="Phases"),
228     }
229
230
231 class Charge(osv.Model):
232     _name = "projet.charge"
233
234     _columns = {
235         "name": fields.char(string="Title", size=64, required=True),
236         "description": fields.text(string="Description"),
237         "teammember_id": fields.many2one("projet.teammember",
238                                          string="Team Member",
239                                          required=True),
240         "phase_id": fields.many2one("projet.phase",
241                                     string="Phase",
242                                     required=True),
243         "evolution_id": fields.many2one("projet.evolution",
244                                     string="Evolution",
245                                     required=True),
246         "mo_id": fields.many2one("projet.mo",
247                                  string="Mo"),
248     }
249
250 class mo(osv.Model):
251     _name = "projet.mo"
252
253     _choses = [("primaire", "Primaire"),
254                ("secondaire", "Secondaire"),
255                ("generique", "Générique")]
256
257     _columns = {
258         "name": fields.char(string="Title"),
259         "description": fields.text(string="Description"),
260         "chose": fields.selection(_choses, string="Chose", required=True),
261         "charges": fields.one2many("projet.charge",
262                                    "mo_id",
263                                    string="Charges"),
264     }
265
266     _defaults = {
267         "chose": "generique"}
268
269
270 class moe(osv.Model):
271     _name = "projet.moe"
272     _inherit = "projet.mo"
273
274     _columns = {
275         "projets": fields.one2many("projet.projet",
276                                      "moe_id",
277                                      string="Projets"),
278     }
279
280
281 class moa(osv.Model):
282     _name= "projet.moa"
283     _inherit = "projet.mo"
284
285     _columns = {
286         "projets": fields.one2many("projet.projet",
287                                      "moa_id",
288                                      string="Projets"),
289     }