Ajout progression des taches par topics
authorAlicia FLOREZ <alicflorez@gmail.com>
Wed, 20 Mar 2013 16:42:06 +0000 (17:42 +0100)
committerAlicia FLOREZ <alicflorez@gmail.com>
Wed, 20 Mar 2013 16:42:06 +0000 (17:42 +0100)
todolist.py
views/todolist.xml

index e55a2c0..9c0ee61 100644 (file)
@@ -166,6 +166,13 @@ class Topic(osv.Model):
         return result
 
 
+    def _progress_tasks(self, cr, uid, ids, field, arg, context=None):
+        result = {}
+        for topic in self.browse(cr, uid, ids, context=context):
+            result[topic.id] = topic.number_tasks and topic.number_tasks_done*100./topic.number_tasks or 0.
+        return result
+
+
     _name = "todolist.topic"
 
     _states = [("Active", "Active"), ("Inactive", "Inactive")]
@@ -178,6 +185,7 @@ class Topic(osv.Model):
         "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"),
+        "progress_tasks": fields.function(_progress_tasks, type="float", string="Number of lists"),
     }
 
     _defaults = {
index 815e892..be81254 100644 (file)
@@ -82,6 +82,7 @@
                             <field name="description" nolabel="1"/>
                             <label for="nb_lists" />
                             <field name="nb_lists" nolabel="1" />
+                            <field name="progress_tasks" colspan="3" widget="progressbar" />
                         </group>
                     </sheet>
                 </form>