Ajout nombre de tache par liste
authorAlicia FLOREZ <alicflorez@gmail.com>
Tue, 19 Mar 2013 16:11:23 +0000 (17:11 +0100)
committerAlicia FLOREZ <alicflorez@gmail.com>
Tue, 19 Mar 2013 16:11:23 +0000 (17:11 +0100)
todolist.py
views/todolist.xml

index 927dc15..c25f457 100644 (file)
@@ -8,6 +8,14 @@ from openerp.osv import osv, fields
 class Container(osv.Model):
     """TODO List : Tasks container"""
 
+
+    def _get_nb_task(self, cr, uid, ids, field, arg, context=None):
+        result = {}
+        for tasks in self.browse(cr, uid, ids, context=context):
+            result[tasks.id] = len(tasks.tasks)
+        return result
+
+
     _name = "todolist.container"
 
     _status = [("draft", "Draft"), ("pending", "Pending"), ("done", "Done")]
@@ -21,6 +29,7 @@ class Container(osv.Model):
         "state": fields.selection(_status, string="State", select=True),
         "tasks": fields.one2many("todolist.task", "container_id", string="Tasks"),
         "topics_id": fields.many2many("todolist.topic", "todolist_container_topic_rel", "container_id", "topic_id", string="Topics", domain=[("activated", "=","Active")]),
+        "number_tasks": fields.function(_get_nb_task, type="integer", string="Number of tasks"),
     }
 
     _defaults = {
index 9fd44fa..600c122 100644 (file)
@@ -20,6 +20,8 @@
                             <field name="name" colspan="2" nolabel="1" />
                             <label for="description" colspan="1" />
                             <field name="description" colspan="2" nolabel="1" />
+                            <label for="number_tasks" colspan="1" />
+                            <field name="number_tasks" colspan="2" nolabel="1" />
                         </group>
                         <notebook colspan="4">
                             <page string="Dates">