Rajout d'une méthode permettant de suspendre un mesurable
authorAlicia FLOREZ <alicflorez@gmail.com>
Tue, 4 Jun 2013 07:54:41 +0000 (09:54 +0200)
committerAlicia FLOREZ <alicflorez@gmail.com>
Tue, 4 Jun 2013 07:54:41 +0000 (09:54 +0200)
axes.py

diff --git a/axes.py b/axes.py
index 8270559..8b2233d 100644 (file)
--- a/axes.py
+++ b/axes.py
@@ -80,7 +80,8 @@ class Mesurable(osv.Model):
 
         self.write(
             cr,
-            uid, ids, {
+            uid,
+            ids, {
                 'date_init_deb' : palier['date_plan_deb'],
                 'date_init_fin' : palier['date_plan_fin'],
                 'statut': 'encours'
@@ -89,6 +90,25 @@ class Mesurable(osv.Model):
         return self
 
 
+    def suspendre(self, cr, uid, ids, context=None):
+        if type(ids) == list:
+            if len(ids) != 1:
+                return # TODO: message d'avertissement
+            ids = ids[0]
+
+        mesurable = self.read(cr, uid, ids, ['statut'], context, context)
+        if mesurable['statut'] != 'encours':
+            return
+        self.write(
+            cr,
+            uid,
+            ids,
+            {'statut': 'suspendu'},
+            context,
+        )
+
+
+
 #------------ TRAVAIL CALCUL JOURS OUVRES ------------
     @staticmethod
     def _get_date_paques(annee):