Wizard pour l'ajout d'évolutions à un projet : Done.
authorAlicia FLOREZ <alicflorez@gmail.com>
Wed, 12 Jun 2013 13:55:55 +0000 (15:55 +0200)
committerAlicia FLOREZ <alicflorez@gmail.com>
Wed, 12 Jun 2013 13:55:55 +0000 (15:55 +0200)
__init__.py
__openerp__.py
views/projet.xml
views/wizards/evolution.xml [new file with mode: 0644]
wizards/evolution.py

index a68caea..9669ced 100644 (file)
@@ -9,4 +9,5 @@ import evolution
 import wizards.domaine
 import wizards.moa
 import wizards.moe
-import wizards.palierPhase
\ No newline at end of file
+import wizards.palierPhase
+import wizards.evolution
index 1cc9e4c..e6c0ff9 100644 (file)
@@ -16,6 +16,7 @@
         'views/wizards/moe.xml',
         'views/wizards/moa.xml',
         'views/wizards/palierPhase.xml',
+        'views/wizards/evolution.xml',
         # Vues associées aux modèles
         'views/phase.xml',
 #        'views/team_member.xml',
index 0cb1a04..4040ff7 100644 (file)
                                 </field>
                             </page>
                             <page string="Evolutions">
+                            <button type="action" target="new" name="%(wizard_add_evolution)d" string="Ajouter une évolution" class="oe_highlight" context="{'project_id': id}" />
                                 <field name="evolutions">
                                     <tree>
                                         <field name="name"/>
diff --git a/views/wizards/evolution.xml b/views/wizards/evolution.xml
new file mode 100644 (file)
index 0000000..2681819
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+  <data>
+
+
+    <!-- View -->
+    <record model="ir.ui.view" id="wizard_add_evolution_form">
+      <field name="name">wizard.evolution</field>
+      <field name="model">cmmi.evolution.wizard</field>
+      <field name="arch" type="xml">
+        <form string="Add Evolution to Project">
+          <field name="name" />
+          <field name="projet_id" readonly="1" />
+          <field name="palier_id" />
+          <field name="chantier_id" />
+          <button type="object" name="action_add_evolution" string="Add Evolution to Project"/>
+        </form>
+      </field>
+    </record>
+
+    <!-- Actions window -->
+    <record model="ir.actions.act_window" id="wizard_add_evolution">
+      <field name="name">Add Evolution to Project</field>
+      <field name="res_model">cmmi.evolution.wizard</field>
+      <field name="view_mode">form</field>
+      <field name="target">new</field>
+    </record>
+
+
+  </data>
+</openerp>
index 9d52231..65a3d85 100644 (file)
@@ -10,9 +10,9 @@ class EvolutionWizard(osv.TransientModel):
 
     def default_get(self, cr, uid, fields, context=None):
         res = osv.TransientModel.default_get(self, cr, uid, fields, context=context)
-        project_id = context.get('project_id', False)
-        if project_id:
-            res['project_id'] = project_id
+        projet_id = context.get('project_id', False)
+        if projet_id:
+            res['projet_id'] = projet_id
         return res
 
 
@@ -25,7 +25,7 @@ class EvolutionWizard(osv.TransientModel):
         palier_ids = palier_model.search(
             cr,
             uid,
-            [('projet_id', '=', context["projet_id"])],
+            [('projet_id', '=', context["project_id"])],
             context=context
         )
 
@@ -46,7 +46,7 @@ class EvolutionWizard(osv.TransientModel):
 
 
     def _chantier_selection(self, cr, uid, context=None):
-        chantier_model = self.pool.get("cmmi.axes.palier")
+        chantier_model = self.pool.get("cmmi.axes.chantier")
 
         if context is None or not context.has_key("project_id"):
             return
@@ -54,7 +54,7 @@ class EvolutionWizard(osv.TransientModel):
         chantier_ids = chantier_model.search(
             cr,
             uid,
-            [('projet_id', '=', context["projet_id"])],
+            [('projet_id', '=', context["project_id"])],
             context=context
         )
 
@@ -74,8 +74,29 @@ class EvolutionWizard(osv.TransientModel):
         )]
 
 
+    def action_add_evolution(self, cr, uid, ids, context=None):
+        evolution_model = self.pool.get("cmmi.evolution")
+
+        id = ids[0]
+
+        res = self.read(cr, uid, id, context=context)
+        evolution_model.create(
+            cr,
+            uid,
+            {
+                "name": res["name"],
+                "palier_id": res["palier_id"],
+                "chantier_id": res["chantier_id"],
+                "projet_id": res["projet_id"][0],
+            },
+            context=context
+        )
+
+        return {'type': 'ir.actions.act_windows_close'}
+
 
     _columns = {
+        "name": fields.char(string="Title", size=64, required=True),
         "projet_id": fields.many2one("cmmi.projet",
                                      string="Projet",
                                      required=True),