Modifications importantes sur MOA et MOE
authorSébastien CHAZALLET <s.chazallet@gmail.com>
Thu, 23 May 2013 14:01:24 +0000 (16:01 +0200)
committerSébastien CHAZALLET <s.chazallet@gmail.com>
Thu, 23 May 2013 14:01:24 +0000 (16:01 +0200)
demo/projet.xml
projet.py
views/projet.xml
wizards/moa.py
wizards/moe.py

index a1da023..b9d1752 100644 (file)
@@ -25,9 +25,9 @@
 
         <record id="projet_projet_1" model="cmmi.projet">
             <field name="name">Projet of the doom</field>
-            <field name="description">Ici c'est la description de ce super projet !</field>
+            <field name="description">Ici c'est la description de ce super projet !</field><!--
             <field name="moe_id" ref="cmmi_moe_0" />
-            <field name="moa_id" ref="cmmi_moa_0" />
+            <field name="moa_id" ref="cmmi_moa_0" />-->
         </record>
 
 
index 454682b..4e2e7a6 100644 (file)
--- a/projet.py
+++ b/projet.py
@@ -9,25 +9,12 @@ class Projet(osv.Model):
 
     _name = "cmmi.projet"
 
-    _domains = {
-        'moe': [('role_mo_id.type_mo', '=', "MOE")],
-        'moa': [('role_mo_id.type_mo', '=', "MOA")],
-    }
-
     _columns = {
         "name": fields.char(string="Title", size=64, required=True),
         "description": fields.text(string="Description"),
         "domaines": fields.one2many("cmmi.projet.domaine",
                                     "project_id",
                                     string="Domaines"),
-        "structures": fields.many2many("cmmi.mo.structure",
-                                       string="Structures"),
-        "structures_moe": fields.many2many("cmmi.mo.structure",
-                                           string="Structures",
-                                           domain=_domains['moe']),
-        "structures_moa": fields.many2many("cmmi.mo.structure",
-                                           string="Structures",
-                                           domain=_domains['moa']),
         "team_members": fields.many2many("cmmi.partner.teammember",
                                          "cmmi_projet_teammember_rel",
                                          "projet_id",
@@ -48,12 +35,24 @@ class Projet(osv.Model):
         "evolutions": fields.one2many("cmmi.evolution",
                                       "projet_id",
                                       string="Evolutions"),
-        "moe_id": fields.many2one("cmmi.mo.moe", string="MoE", required=True),
-        "moa_id": fields.many2one("cmmi.mo.moa", string="MoA", required=True),
-        "main_domain": fields.many2one("cmmi.description.domaine",
-                                       string="Domaine principal"),
-        "main_structure": fields.many2one("cmmi.mo.structure",
-                                          string="Structure principale"),
+        "moe_ids": fields.one2many("cmmi.projet.moe",
+                                   "project_id",
+                                   string="MOEs"),
+        "moa_ids": fields.one2many("cmmi.projet.moa",
+                                   "project_id",
+                                   string="MOAs"),
+        "moe_id": fields.one2many("cmmi.projet.moe",
+                                  "project_id",
+                                  string="MOE principale",
+                                  domaine=[('main', '=', True)]),
+        "moa_id": fields.one2many("cmmi.projet.moa",
+                                  "project_id",
+                                  string="MOA principale",
+                                  domaine=[('main', '=', True)]),
+        "main_domain": fields.one2many("cmmi.projet.domaine",
+                                       "project_id",
+                                       string="Domaine principal",
+                                       domaine=[('main', '=', True)]),
     }
 
     def action_add_domain(self, cr, uid, ids, context=None):
@@ -143,9 +142,12 @@ class ProjetMoe(osv.Model):
                                       string="MOE"),
     }
 
+    def onchange_main(self, cr, uid, ids, project, moe, main, context=None):
+        pass
+
 
 class ProjetMoa(osv.Model):
-    _name = "cmmi.projet.moe"
+    _name = "cmmi.projet.moa"
 
     def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
         if isinstance(ids, (int, long)):
@@ -165,6 +167,9 @@ class ProjetMoa(osv.Model):
                                       string="MOA"),
     }
 
+    def onchange_main(self, cr, uid, ids, project, moa, main, context=None):
+        pass
+
 
 class ProjetPhase(osv.Model):
     _name = "cmmi.projet.phase"
index 40d263e..3d150aa 100644 (file)
                         <field name="name" nolabel="1" />
                         <notebook colspan="4">
                             <page string="Projet">
-                                <field name="description" nolabel="1" />
+                                <field name="description" nolabel="1" /><!--
                                 <label for="moe_id" colspan="1" />
                                 <field name="moe_id" nolabel="1" />
                                 <label for="moa_id" colspan="1" />
                                 <field name="moa_id" nolabel="1" />
                                 <label for="main_domain" colspan="1" />
-                                <field name="main_domain" nolabel="1" widget="selection" />
+                                <field name="main_domain" nolabel="1" widget="selection" />-->
                             </page>
                             <page string="MO">
                                 <p>MOE</p>
                                 <button type="action" target="new" name="cmmi.wizard_add_moe_to_project" string="Add a MOE" class="oe_highlight" context="{'project_id': id}" />
-                                <field name="structures_moe">
-                                    <tree>
+                                <field name="moe_ids">
+                                    <tree create="false" delete="true" editable="true">
+                                        <field name="project_id" invisible="1" />
+                                        <field name="moe_id" invisible="1" />
                                         <field name="name" />
-                                        <field name="description" />
-                                        <field name="role_mo_id" />
+                                        <field name="main" on_change="onchange_main(project_id, moe_id, main)" />
                                     </tree>
                                 </field>
                                 <p>MOA</p>
                                 <button type="action" target="new" name="cmmi.wizard_add_moa_to_project" string="Add a MOA" class="oe_highlight" context="{'project_id': id}" />
-                                <field name="structures_moe">
-                                    <tree>
+                                <field name="moa_ids">
+                                    <tree create="false" delete="true" editable="true">
+                                        <field name="project_id" invisible="1" />
+                                        <field name="moa_id" invisible="1" />
                                         <field name="name" />
-                                        <field name="description" />
-                                        <field name="role_mo_id" />
-                                        <field name="statut" />
+                                        <field name="main" on_change="onchange_main(project_id, moa_id, main)" />
                                     </tree>
                                 </field>
                             </page>
index 28232a5..20d7816 100644 (file)
@@ -62,7 +62,7 @@ class ProjetMoaWizard(osv.TransientModel):
         )]
 
 
-    def action_add_domain_to_project(self, cr, uid, ids, context=None):
+    def action_add_moa_to_project(self, cr, uid, ids, context=None):
         # Récupération du modèle utile pour écrire les données
         model = self.pool.get("cmmi.projet.moa")
 
index 37399bc..b5af893 100644 (file)
@@ -62,7 +62,7 @@ class ProjetMoeWizard(osv.TransientModel):
         )]
 
 
-    def action_add_domain_to_project(self, cr, uid, ids, context=None):
+    def action_add_moe_to_project(self, cr, uid, ids, context=None):
         # Récupération du modèle utile pour écrire les données
         model = self.pool.get("cmmi.projet.moe")