3 from openerp.osv import osv, fields
8 class Container(osv.Model):
9 """TODO List : Tasks container"""
11 _name = "todolist.container"
13 _status = [("draft", "Draft"), ("pending", "Pending"), ("done", "Done")]
16 "name": fields.char(string="Title", size=64, required=True),
17 "description": fields.text(string="Description"),
18 "target": fields.date(string="Target", help="Target Date"),
19 "milestone": fields.date(string="Milestone", help="Due date"),
20 "manday": fields.float(string="Man-Days", digits=(6, 2)),
21 "state": fields.selection(_status, string="State", select=True),
22 "tasks": fields.one2many("todolist.task", "container_id", string="Tasks"),
23 "topics_id": fields.many2many("todolist.topic", "todolist_container_topic_rel", "container_id", "topic_id", string="Topics", domain=[("activated", "=","Active")]),
32 "name_different_from_description_constraint",
33 "CHECK(name <> description)",
34 "Fields name and description should be different",
37 "target_before_milestone_constraint",
38 "CHECK(target < milestone)",
39 "The target date should be previous milestone date",
43 def action_start(self, cr, uid, ids, context=None):
44 self.write(cr, uid, ids, {"state": "pending"}, context=context)
48 def action_stop(self, cr, uid, ids, context=None):
49 self.write(cr, uid, ids, {"state": "done"}, context=context)
53 def action_restart(self, cr, uid, ids, context=None):
54 self.write(cr, uid, ids, {"state": "draft"}, context=context)
60 class Task(osv.Model):
61 """TODO List : A task (something to do in a to do list)"""
63 _name = "todolist.task"
65 _priorities = [("useful", "Useful"), ("necessary", "Necessary"), ("essential", "Essential")]
67 _states = [("draft", "Draft"), ("proposal", "Proposal"), ("approved", "Approved"), ("started", "Started"), ("done", "Done")]
70 "name": fields.char(string="Title", size=64, required=True),
71 "description": fields.text(string="Description"),
72 "planned": fields.date(string="Planed"),
73 "milestone": fields.date(string="Milestone"),
74 "manday": fields.integer(string="Man-Days"),
75 "priority": fields.selection(_priorities, string="Priority", select=True),
76 "state": fields.selection(_states, string="State", select=True),
77 "container_id": fields.many2one("todolist.container", string="To do list", required=True),
84 def action_draft(self, cr, uid, ids, context=None):
85 self.write(cr, uid, ids, {"state": "draft"}, context=context)
88 def action_propose(self, cr, uid, ids, context=None):
89 self.write(cr, uid, ids, {"state": "proposal"}, context=context)
92 def action_approve(self, cr, uid, ids, context=None):
93 self.write(cr, uid, ids, {"state": "approved"}, context=context)
96 def action_start(self, cr, uid, ids, context=None):
97 self.write(cr, uid, ids, {"state": "started"}, context=context)
100 def action_done(self, cr, uid, ids, context=None):
101 self.write(cr, uid, ids, {"state": "done"}, context=context)
105 # ------------------- class Theme ------------------- #
107 class Topic(osv.Model):
108 """TODO List : Container"s Topic"""
110 _name = "todolist.topic"
112 _states = [("Active", "Active"), ("Inactive", "Inactive")]
115 "name": fields.char(string="Title", size=64, required=True),
116 "description": fields.text(string="Description"),
117 "activated": fields.selection(_states, string="State", select=True),
118 "todolist_ids": fields.many2many("todolist.container", "todolist_container_topic_rel", "topic_id", "Container_id", string="TO DO Lists"),
122 "activated": "Active",