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

index 2935ab6..3c81f5e 100644 (file)
@@ -150,6 +150,14 @@ class Topic(osv.Model):
         return result
 
 
+    def _get_number_tasks(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
+        return result
+
+
     _name = "todolist.topic"
 
     _states = [("Active", "Active"), ("Inactive", "Inactive")]
@@ -160,6 +168,7 @@ class Topic(osv.Model):
         "activated": fields.selection(_states, string="State", select=True),
         "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"),
     }
 
     _defaults = {