Rajout d'une méthode permettant de terminer un mesurable
authorAlicia FLOREZ <alicflorez@gmail.com>
Tue, 4 Jun 2013 08:49:14 +0000 (10:49 +0200)
committerAlicia FLOREZ <alicflorez@gmail.com>
Tue, 4 Jun 2013 08:49:14 +0000 (10:49 +0200)
axes.py

diff --git a/axes.py b/axes.py
index a48e86a..5ef14ed 100644 (file)
--- a/axes.py
+++ b/axes.py
@@ -106,6 +106,25 @@ class Mesurable(osv.Model):
             {'state': 'suspendu'},
             context,
         )
+        return self
+
+    def terminer(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, ['state'], context, context)
+        if mesurable['state'] != 'encours':
+            return
+        self.write(
+            cr,
+            uid,
+            ids,
+            {'state': 'termine'},
+            context,
+        )
+        return self