Ajout verification milestone de la tache < milestone de la liste
authorAlicia FLOREZ <alicflorez@gmail.com>
Fri, 22 Mar 2013 11:00:11 +0000 (12:00 +0100)
committerAlicia FLOREZ <alicflorez@gmail.com>
Fri, 22 Mar 2013 11:00:11 +0000 (12:00 +0100)
todolist.py

index 6812316..e75175b 100644 (file)
@@ -141,7 +141,7 @@ class Task(osv.Model):
         ),
         (
             "manday_sup_0_constraint",
-            "CHECK(manday < 0)",
+            "CHECK(manday > 0)",
             "The manday should be positive",
         ),
     ]
@@ -167,13 +167,19 @@ class Task(osv.Model):
         self.write(cr, uid, ids, {"state": "done"}, context=context)
         return self
 
+    #chaque utilisateur voit seulement ces taches
     def search(self, cr, user, args=[], offset=0, limit=None, order=None, context=None, count=False):
         args.append(("create_uid", "=", user))
         if len(args) != 1:
             args.insert(0, "&")
         return osv.Model.search(self, cr, user, args, offset, limit, order, context, count)
 
-
+    def write(self, cr, user, ids, vals, context=None):
+        if "milestone" in vals.keys():
+            for task in self.browse(cr, user, ids, context=context):
+                if task.container_id.milestone < vals["milestone"]:
+                    vals["milestone"] = task.container_id.milestone
+        return osv.Model.write(self, cr, user, ids, vals, context)
 
 
 class Topic(osv.Model):