Sur container, ajout du chatter
[OpenERP/todolist.git] / todolist.py
index 10f855f..43ca790 100644 (file)
@@ -30,16 +30,24 @@ class Container(osv.Model):
         return result
 
 
+    #================================================================================
+    # def copy(self, cr, uid, id, default, context=None):
+    #    container = self.browse(cr, uid, id, context=context)
+    #    new_name =  "Copy of %s" % container.name
+    #    # =like is the original LIKE operator from SQL
+    #    others_count = self.search(cr,  uid, [('name', '=like', new_name+'%')],
+    #                               count=True, context=context)
+    #    if others_count > 0:
+    #        new_name = "%s (%s)" % (new_name, others_count+1)
+    #    default['name'] = new_name
+    #    return osv.Model.copy(self, cr, uid, id, default, context=context)
+    #================================================================================
+
+
     def copy(self, cr, uid, id, default, context=None):
-        container = self.browse(cr, uid, id, context=context)
-        new_name =  "Copy of %s" % container.name
-        # =like is the original LIKE operator from SQL
-        others_count = self.search(cr,  uid, [('name', '=like', new_name+'%')],
-                                   count=True, context=context)
-        if others_count > 0:
-            new_name = "%s (%s)" % (new_name, others_count+1)
-        default['name'] = new_name
-        return osv.Model.copy(self, cr, uid, id, default, context=context)
+        cr.execute("SELECT copierContainer (%s);", (id,))
+        return cr.fetchone()[0]
+
 
     def _get_manday(self, cr, uid, ids, field, arg, context=None):
         result={}
@@ -50,6 +58,8 @@ class Container(osv.Model):
 
     _name = "todolist.container"
 
+    _inherit = "mail.thread"
+
     _status = [("draft", "Draft"), ("pending", "Pending"), ("done", "Done")]
 
     _columns = {
@@ -112,6 +122,8 @@ class Task(osv.Model):
 
     _name = "todolist.task"
 
+    _inherit = "mail.thread"
+
     _priorities = [("Useful", "Useful"), ("Necessary", "Necessary"), ("Essential", "Essential")]
 
     _states = [("draft", "Draft"), ("proposal", "Proposal"), ("approved", "Approved"), ("started", "Started"), ("done", "Done")]
@@ -147,7 +159,7 @@ class Task(osv.Model):
         ),
         (
             "manday_sup_0_constraint",
-            "CHECK(manday > 0)",
+            "CHECK(manday >= 0)",
             "The manday should be positive",
         ),
     ]