Ajout champs fonction pour nb de taches terminé par topics
authorAlicia FLOREZ <alicflorez@gmail.com>
Wed, 20 Mar 2013 16:34:54 +0000 (17:34 +0100)
committerAlicia FLOREZ <alicflorez@gmail.com>
Wed, 20 Mar 2013 16:34:54 +0000 (17:34 +0100)
todolist.py

index 3c81f5e..e55a2c0 100644 (file)
@@ -158,6 +158,14 @@ class Topic(osv.Model):
         return result
 
 
+    def _get_number_tasks_done(self, cr, uid, ids, field, arg, context=None):
+        result = 0
+        for topic in self.browse(cr, uid, ids, context=context):
+            for container in self.browse(cr, uid, ids, context=context):
+                result += container.number_tasks_done
+        return result
+
+
     _name = "todolist.topic"
 
     _states = [("Active", "Active"), ("Inactive", "Inactive")]
@@ -169,6 +177,7 @@ class Topic(osv.Model):
         "todolist_ids": fields.many2many("todolist.container", "todolist_container_topic_rel", "topic_id", "Container_id", string="TO DO Lists"),
         "nb_lists": fields.function(_get_nb_lists, type="integer", string="Number of lists"),
         "number_tasks": fields.function(_get_number_tasks, type="integer", string="Number of lists"),
+        "number_tasks_done": fields.function(_get_number_tasks_done, type="integer", string="Number of lists"),
     }
 
     _defaults = {