From 44a2ce109fdaec7d70ce008a007e5bf801482905 Mon Sep 17 00:00:00 2001 From: Alicia FLOREZ Date: Wed, 20 Mar 2013 17:33:57 +0100 Subject: [PATCH] Ajout champs fonction pour nb de taches par topics --- todolist.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/todolist.py b/todolist.py index 2935ab6..3c81f5e 100644 --- a/todolist.py +++ b/todolist.py @@ -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 = { -- 1.7.10.4