Rajout de champs à la classe projet.phase
[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         "projet_id": fields.many2one("projet.projet",
146                                      string="Projet",
147                                      required=True),
148         "charges": fields.one2many("projet.charge",
149                                    "phase_id",
150                                    string="Charges"),
151         "evolutions": fields.one2many("projet.evolution",
152                                       "phase_id",
153                                       string="Evolutions"),
154         "palier_id": fields.many2one("projet.palier",
155                                      string="Palier"),
156     }
157
158 #TODO trouver un nom a cette chose
159 class qqch(osv.Model):
160     _name = "projet.qqch"
161
162     _columns = {
163         "name": fields.char(string="Title", size=64, required=True),
164         "description": fields.text(string="Description"),
165         "date_jalon": fields.date(sring="Jalon"),
166         "date_init_deb": fields.date(sring="Date initiale début"),
167         "date_init_fin": fields.date(sring="Date initiale de fin"),
168         "date_plan_deb": fields.date(string="Date plannifiée début"),
169         "date_plan_fin": fields.date(string="Date plannifiée de fin"),
170         "date_reel_deb": fields.date(string="Data réelle début"),
171         "date_reel_fin": fields.date(string="Data réelle fin"),
172     }
173
174     _sql_constraints = [
175         (
176             "date_init_deb_before_date_init_fin",
177             "CHECK(date_init_deb<> date_init_fin)",
178             "The date_init_deb should be previous date_init_fin",
179         ),
180         (
181             "date_plan_deb_before_date_plan_fin",
182             "CHECK(date_plan_deb <> date_plan_fin)",
183             "The date_plan_deb should be previous date_plan_fin",
184         ),
185         (
186             "date_reel_deb_before_date_reel_fin",
187             "CHECK(date_reel_deb<> date_reel_fin)",
188             "The date_reel_deb should be previous date_reel_fin",
189         ),
190     ]
191
192
193 class Chantier(osv.Model):
194     _name = "projet.chantier"
195
196     _inherit = "projet.qqch"
197
198     _columns = {
199         "projet_id": fields.many2one("projet.projet",
200                                      string="Projet",
201                                      required=True),
202         "evolutions": fields.one2many("projet.evolution",
203                                       "chantier_id",
204                                       string="Evolutions"),
205     }
206
207
208 class Palier(osv.Model):
209     _name = "projet.palier"
210
211     _inherit = "projet.qqch"
212
213     _columns = {
214         "projet_id": fields.many2one("projet.projet",
215                                      string="Projet",
216                                      required=True),
217         "evolutions": fields.one2many("projet.evolution",
218                                       "palier_id",
219                                       string="Evolutions"),
220         "phases": fields.one2many("projet.phase",
221                                   "palier_id",
222                                   string="Phases"),
223     }
224
225
226 class Charge(osv.Model):
227     _name = "projet.charge"
228
229     _columns = {
230         "name": fields.char(string="Title", size=64, required=True),
231         "description": fields.text(string="Description"),
232         "teammember_id": fields.many2one("projet.teammember",
233                                          string="Team Member",
234                                          required=True),
235         "phase_id": fields.many2one("projet.phase",
236                                     string="Phase",
237                                     required=True),
238         "evolution_id": fields.many2one("projet.evolution",
239                                     string="Evolution",
240                                     required=True),
241         "mo_id": fields.many2one("projet.mo",
242                                  string="Mo"),
243     }
244
245 class mo(osv.Model):
246     _name = "projet.mo"
247
248     _choses = [("primaire", "Primaire"),
249                ("secondaire", "Secondaire"),
250                ("generique", "Générique")]
251
252     _columns = {
253         "name": fields.char(string="Title"),
254         "description": fields.text(string="Description"),
255         "chose": fields.selection(_choses, string="Chose", required=True),
256         "charges": fields.one2many("projet.charge",
257                                    "mo_id",
258                                    string="Charges"),
259     }
260
261     _defaults = {
262         "chose": "generique"}
263
264
265 class moe(osv.Model):
266     _name = "projet.moe"
267     _inherit = "projet.mo"
268
269     _columns = {
270         "projets": fields.one2many("projet.projet",
271                                      "moe_id",
272                                      string="Projets"),
273     }
274
275
276 class moa(osv.Model):
277     _name= "projet.moa"
278     _inherit = "projet.mo"
279
280     _columns = {
281         "projets": fields.one2many("projet.projet",
282                                      "moa_id",
283                                      string="Projets"),
284     }