Ajout du nombre de list pour les topics
authorAlicia FLOREZ <alicflorez@gmail.com>
Wed, 20 Mar 2013 15:08:17 +0000 (16:08 +0100)
committerAlicia FLOREZ <alicflorez@gmail.com>
Wed, 20 Mar 2013 15:08:17 +0000 (16:08 +0100)
todolist.py
views/todolist.xml

index fee9aea..a919d15 100644 (file)
@@ -153,6 +153,13 @@ class Task(osv.Model):
 class Topic(osv.Model):
     """TODO List : Container"s Topic"""
 
+    def _get_nb_lists(self, cr, uid, ids, field, arg, context=None):
+        result = {}
+        for topic in self.browse(cr, uid, ids, context=context):
+            result[topic.id] = len(topic.todolist_ids)
+        return result
+
+
     _name = "todolist.topic"
 
     _states = [("Active", "Active"), ("Inactive", "Inactive")]
@@ -162,6 +169,7 @@ class Topic(osv.Model):
         "description": fields.text(string="Description"),
         "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"),
     }
 
     _defaults = {
index c638e92..6e84165 100644 (file)
@@ -78,6 +78,8 @@
                         <group col="1">
                             <label for="description"/>
                             <field name="description" nolabel="1"/>
+                            <label for="nb_lists" />
+                            <field name="nb_lists" nolabel="1" />
                         </group>
                     </sheet>
                 </form>