Changement du name des topics : todolist.topic en semantics.topic
[OpenERP/todolist.git] / todolist.py
index e1be67c..1e2af45 100644 (file)
@@ -3,8 +3,7 @@
 from openerp.osv import osv, fields
 
 
-
-
+# ------------- CONTAINER ------------- #
 class Container(osv.Model):
     """TODO List : Tasks container"""
 
@@ -58,6 +57,8 @@ class Container(osv.Model):
 
     _name = "todolist.container"
 
+    _inherit = "mail.thread"
+
     _status = [("draft", "Draft"), ("pending", "Pending"), ("done", "Done")]
 
     _columns = {
@@ -68,7 +69,12 @@ class Container(osv.Model):
         "manday": fields.function(_get_manday, type="integer", string="Man-Days"),
         "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")]),
+        "topic_ids": fields.many2many("semantics.topic",
+                                      "todolist_container_topic_rel",
+                                      "todolist_ids",
+                                      "topic_ids",
+                                      string="Topics",
+                                      domain=[("activated", "=","Active")]),
         "number_tasks": fields.function(_get_nb_tasks, type="integer", string="Number of tasks"),
         "number_tasks_done": fields.function(_get_nb_tasks_done, type="integer", string="Number of tasks done"),
         "progress_tasks": fields.function(_tasks_progress, type="float", string="Progression"),
@@ -86,7 +92,7 @@ class Container(osv.Model):
         ),
         (
             "target_before_milestone_constraint",
-            "CHECK(target < milestone)",
+            "CHECK(target <= milestone)",
             "The target date should be previous milestone date",
         ),
     ]
@@ -115,11 +121,14 @@ class Container(osv.Model):
         return osv.Model.search(self, cr, user, args, offset, limit, order, context, count)
 
 
+# ------------- TASK ------------- #
 class Task(osv.Model):
     """TODO List : A task (something to do in a to do list)"""
 
     _name = "todolist.task"
 
+    _inherit = "mail.thread"
+
     _priorities = [("Useful", "Useful"), ("Necessary", "Necessary"), ("Essential", "Essential")]
 
     _states = [("draft", "Draft"), ("proposal", "Proposal"), ("approved", "Approved"), ("started", "Started"), ("done", "Done")]
@@ -150,7 +159,7 @@ class Task(osv.Model):
         ),
         (
             "planned_before_milestone_constraint",
-            "CHECK(planned < milestone)",
+            "CHECK(planned <= milestone)",
             "The planned date should be previous milestone date",
         ),
         (
@@ -203,7 +212,7 @@ class Task(osv.Model):
             vals["milestone"] = milestone
         return osv.Model.create(self, cr, user, vals, context=context)
 
-
+# ------------- TOPIC ------------- #
 class Topic(osv.Model):
     """TODO List : Container"s Topic"""
 
@@ -235,15 +244,19 @@ class Topic(osv.Model):
         return result
 
 
-    _name = "todolist.topic"
+    _name = "semantics.topic"
+
+    _inherit = "semantics.topic"
 
     _states = [("Active", "Active"), ("Inactive", "Inactive")]
 
     _columns = {
-        "name": fields.char(string="Title", size=64, required=True),
-        "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"),
+        "todolist_ids": fields.many2many("todolist.container",
+                                         "todolist_container_topic_rel",
+                                         "topic_ids",
+                                         "todolist_ids",
+                                         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 tasks"),
         "number_tasks_done": fields.function(_get_number_tasks_done, type="integer", string="Number of tasks done"),
@@ -253,12 +266,3 @@ class Topic(osv.Model):
     _defaults = {
         "activated": "Active",
     }
-
-
-    _sql_constraints = [
-        (
-            "name_different_from_description_constraint",
-            "CHECK(name <> description)",
-            "Fields name and description should be different",
-        ),
-    ]