Ajout d'un bouton lançant un palier
authorAlicia FLOREZ <alicflorez@gmail.com>
Mon, 3 Jun 2013 16:26:07 +0000 (18:26 +0200)
committerAlicia FLOREZ <alicflorez@gmail.com>
Mon, 3 Jun 2013 16:26:07 +0000 (18:26 +0200)
axes.py
views/palier.xml

diff --git a/axes.py b/axes.py
index 7d638cb..0c78468 100644 (file)
--- a/axes.py
+++ b/axes.py
@@ -44,6 +44,10 @@ class Mesurable(osv.Model):
                                             string="Nombre de jour"),
     }
 
+    _defaults = {
+        "statut": "cree",
+    }
+
     _sql_constraints = [
         (
             "date_init_deb_before_date_init_fin",
@@ -63,6 +67,28 @@ class Mesurable(osv.Model):
     ]
 
 
+    def commencer(self, cr, uid, ids, context=None):
+        if type(ids) == list:
+            if len(ids) != 1:
+                return # TODO: message d'avertissement
+            ids = ids[0]
+
+        palier = self.read(cr, uid, ids, ['date_plan_deb', 'date_plan_fin', 'statut'], context)
+
+        if palier['statut'] != 'cree':
+            return
+
+        self.write(
+            cr,
+            uid, ids, {
+                'date_init_deb' : palier['date_plan_deb'],
+                'date_init_fin' : palier['date_plan_fin'],
+                'statut': 'encours'
+            },
+            context)
+        return self
+
+
 #------------ TRAVAIL CALCUL JOURS OUVRES ------------
     @staticmethod
     def _get_date_paques(annee):
@@ -182,7 +208,6 @@ class Palier(osv.Model):
                     'palier_id': palier_id,
                 }
             )
-
         return palier_id
 
 
index 1656f9a..d53d36c 100644 (file)
@@ -14,6 +14,8 @@
                         <group colspan="4" col="6">
                             <field name="name"  colspan="4"/>
                             <field name="type_palier"  colspan="2"/>
+                            <button string="Commencer le palier" type="object" name="commencer" class="oe_highlight" />
+
                         </group>
                         <notebook colspan="4">
                             <page string="Détails">