Modification de la relation projet/phase en many2many : création d'une table de relation
authorAlicia FLOREZ <alicflorez@gmail.com>
Thu, 23 May 2013 13:01:55 +0000 (15:01 +0200)
committerAlicia FLOREZ <alicflorez@gmail.com>
Thu, 23 May 2013 13:01:55 +0000 (15:01 +0200)
description.py
phase.py
projet.py
views/phase.xml
views/projet.xml

index 0683d46..96516a3 100644 (file)
@@ -32,7 +32,7 @@ class Domaine(osv.Model):
         "ordre": fields.integer(string="Ordre"),
         "parent_id": fields.many2one("cmmi.description.domaine", string="Parent_id"),
         "statut": fields.selection(_statuts, string="Statut"),
-        "projets": fields.many2many("cmmi.projet",
+        "projets": fields.many2many("cmmi.projet", #TODO enlever ?
                                     string="Projets"),
     }
 
index 7647037..13392df 100644 (file)
--- a/phase.py
+++ b/phase.py
@@ -28,9 +28,6 @@ class Phase(osv.Model):
         "statut": fields.selection(_statuts, string="Statut"),
         "type_phase_id": fields.many2one("cmmi.phase.type",
                                          string="Type phase"),
-        "projet_id": fields.many2one("cmmi.projet",
-                                     string="Projet",
-                                     required=True),
         "charges": fields.one2many("cmmi.evolution.charge",
                                    "phase_id",
                                    string="Charges"),
index dd108b2..4bade4a 100644 (file)
--- a/projet.py
+++ b/projet.py
@@ -42,7 +42,7 @@ class Projet(osv.Model):
         "paliers": fields.one2many("cmmi.axes.palier",
                                    "projet_id",
                                    string="Paliers"),
-        "phases": fields.one2many("cmmi.phase",
+        "phases": fields.one2many("cmmi.projet.phase",
                                   "projet_id",
                                   string="Phases"),
         "evolutions": fields.one2many("cmmi.evolution",
@@ -59,6 +59,7 @@ class Projet(osv.Model):
     def action_add_domain(self, cr, uid, ids, context=None):
         pass
 
+
 class ProjetDomaine(osv.Model):
 
     _name = "cmmi.projet.domaine"
@@ -122,13 +123,13 @@ class ProjetMoe(osv.Model):
     def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if isinstance(ids, (int, long)):
             ids = [ids]
-        return dict([(i, r.domaine_id.name) for i, r in
+        return dict([(i, r.moe_id.name) for i, r in
                 zip(ids, self.browse(cr, uid, ids, context=context))])
 
     _columns = {
         "name": fields.function(_get_name,
                                 type='char',
-                                store=True,
+                                store=True, # Permet d'enregistrer le champ.
                                 string="Nom de la MOE"),
         "main": fields.boolean(string="MOE principale ?"),
         "project_id": fields.many2one("cmmi.projet",
@@ -144,7 +145,7 @@ class ProjetMoa(osv.Model):
     def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if isinstance(ids, (int, long)):
             ids = [ids]
-        return dict([(i, r.domaine_id.name) for i, r in
+        return dict([(i, r.moa_id.name) for i, r in
                 zip(ids, self.browse(cr, uid, ids, context=context))])
 
     _columns = {
@@ -157,4 +158,26 @@ class ProjetMoa(osv.Model):
                                       string="Projet"),
         "moa_id": fields.many2one("cmmi.mo.moa",
                                       string="MOA"),
+    }
+
+
+class ProjetPhase(osv.Model):
+    _name = "cmmi.projet.phase"
+
+    def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
+        if isinstance(ids, (int, long)):
+            ids = [ids]
+        return dict([(i, r.phase_id.name) for i, r in
+                zip(ids, self.browse(cr, uid, ids, context=context))])
+
+    _columns = {
+        "name": fields.function(_get_name,
+                                type='char',
+                                store=True,
+                                string="Nom de la phase"),
+        "selectionne": fields.boolean(string="Phase sélectionnée ?"),
+        "projet_id": fields.many2one("cmmi.projet",
+                                     string="Projet"),
+        "phase_id": fields.many2one("cmmi.phase",
+                                    string="Phase"),
     }
\ No newline at end of file
index 4abee83..b6bfd69 100644 (file)
@@ -22,7 +22,6 @@
                                     <field name="description" />
                                     <field name="statut" colspan="2" />
                                     <field name="type_phase_id" colspan="2" />
-                                    <field name="projet_id" colspan="2" />
                                     <field name="palier_id" colspan="2" />
                                 </group>
                             </page>
index 892c107..1c282a3 100644 (file)
                                 </field>
                             </page>
                             <page string="Phases">
-                                <field name="phases">
-                                    <tree>
-                                        <field name="name" />
-                                        <field name="description" />
-                                    </tree>
-                                </field>
+                                <field name="phases" />
                             </page>
                             <page string="Evolutions">
                                 <field name="evolutions">