Correction wizard MOA et MOE
[OpenERP/cmmi.git] / mo.py
1 #-*- coding: utf8 -*-
2 '''
3 Ce module contient tout ce qui est nécessaire pour qualifier une MO
4
5 On distingue deux grands rôles qui sont les MOE et les MOA :
6
7 MOE = Maîtrise d'oeuvre (ceuf qui font)
8 MOA = Maîtrise d'ouvrage (ceux qui demandent et contrôlent)
9 '''
10
11 from openerp.osv import osv, fields
12
13
14 class RoleMO(osv.Model):
15     """Role MO: différents types de MOE et MOA"""
16
17     _name = "cmmi.mo.role"
18
19     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
20
21     _types_mo = [("MOE", "MOE"), ("MOA", "MOA")]
22
23     _columns = {
24         "name": fields.char(string="Title", size=64, required=True),
25         "code": fields.char(string="Code", size=8, required=True),
26         "description": fields.text(string="Description"),
27         "statut": fields.selection(_statuts, string="Statut"),
28         "type_mo": fields.selection(_types_mo,
29                                     string="Type de MO",
30                                     required=True),
31         "structures": fields.one2many("cmmi.mo.structure",
32                                       "role_mo_id",
33                                       string="MOs"),
34         "mo_ids": fields.one2many("cmmi.mo",
35                                   "role_mo_id",
36                                   string="MOs"),
37     }
38
39
40 class Mo(osv.Model):
41     _name = "cmmi.mo"
42
43     _rangs = [("primaire", "Primaire"),
44               ("secondaire", "Secondaire"),
45               ("generique", "Générique")]
46
47     _columns = {
48         "name": fields.char(string="Title"),
49         "description": fields.text(string="Description"),
50         "rang": fields.selection(_rangs, string="Rang", required=True),
51         "role_mo_id": fields.many2one("cmmi.mo.role", string="Role"),
52         "charges": fields.one2many("cmmi.evolution.charge",
53                                    "mo_id",
54                                    string="Charges"),
55     }
56
57     _defaults = {
58         "rang": "primaire"}
59
60
61 class Moe(osv.Model):
62     _name = "cmmi.mo.moe"
63     _inherit = "cmmi.mo"
64
65     _columns = {
66         "projets": fields.one2many("cmmi.projet",
67                                    "moe_id",
68                                    string="Projets"),
69     }
70
71
72
73 class Moa(osv.Model):
74     _name = "cmmi.mo.moa"
75     _inherit = "cmmi.mo"
76
77     _columns = {
78         "projets": fields.one2many("cmmi.projet",
79                                    "moa_id",
80                                    string="Projets"),
81     }
82
83
84 class Structure(osv.Model):
85
86     _name = "cmmi.mo.structure"
87
88     _statuts = [("actif", "Actif"), ("inactif", "Inactif")]
89
90     _columns = {
91         "name": fields.char(string="Title", size=64, required=True),
92         "code": fields.char(string="Code", size=8, required=True),
93         "description": fields.text(string="Description"),
94         "parent_id": fields.many2one("cmmi.mo.structure", string="Parent_id"),
95         "statut": fields.selection(_statuts, string="Statut"),
96         "role_mo_id": fields.many2one("cmmi.mo.role", string="Role MO"),
97         "projets": fields.many2many("cmmi.projet",
98                                     "projet_projet_structure_rel",
99                                     "structures",
100                                     string="Projets"),
101     }