From 7540b76fe9a01892eb3f53b4dad608d46de26135 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Fri, 16 Mar 2012 16:12:10 +0530 Subject: [PATCH 1/7] [IMP] create notification methods for states and stages and overwrite get_needaction_user_ids method. bzr revid: bth@tinyerp.com-20120316104210-nzm9hd7f9iif6h9z --- addons/project/project.py | 92 ++++++++++++++++++++++++++------- addons/project/project_view.xml | 7 +-- 2 files changed, 74 insertions(+), 25 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 9966ad02ee8..4d61245d868 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -457,6 +457,7 @@ class task(osv.osv): _description = "Task" _log_create = True _date_name = "date_start" + _inherit = ['mail.thread'] def _resolve_project_id_from_context(self, cr, uid, context=None): @@ -845,8 +846,7 @@ class task(osv.osv): if not task.date_end: vals.update({ 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}) self.write(cr, uid, [task.id],vals, context=context) - message = _("The task '%s' is done") % (task.name,) - self.log(cr, uid, task.id, message) + self.case_close_send_note(cr, uid, [task.id], context) return True def do_reopen(self, cr, uid, ids, context=None): @@ -866,6 +866,7 @@ class task(osv.osv): }, context=context) self.write(cr, uid, [task.id], {'state': 'open'}, context=context) + self.case_open_send_note(cr, uid, [task.id], context) return True def do_cancel(self, cr, uid, ids, context={}): @@ -884,8 +885,7 @@ class task(osv.osv): 'ref_doc1': 'project.task,%d' % task.id, 'ref_doc2': 'project.project,%d' % project.id, }, context=context) - message = _("The task '%s' is cancelled.") % (task.name,) - self.log(cr, uid, task.id, message) + self.case_cancel_send_note(cr, uid, [task.id], context) self.write(cr, uid, [task.id], {'state': 'cancelled', 'remaining_hours':0.0}, context=context) return True @@ -897,12 +897,12 @@ class task(osv.osv): if not t.date_start: data['date_start'] = time.strftime('%Y-%m-%d %H:%M:%S') self.write(cr, uid, [t.id], data, context=context) - message = _("The task '%s' is opened.") % (t.name,) - self.log(cr, uid, t.id, message) + self.case_open_send_note(cr, uid, [t.id], context) return True def do_draft(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'draft'}, context=context) + self.case_draft_send_note(cr, uid, ids, context) return True @@ -941,20 +941,16 @@ class task(osv.osv): 'name': newname, }, context=context) if delegate_data['state'] == 'pending': - self.do_pending(cr, uid, task.id, context=context) + self.do_pending(cr, uid, [task.id], context=context) elif delegate_data['state'] == 'done': - self.do_close(cr, uid, task.id, context=context) - - message = _("The task '%s' has been delegated to %s.") % (delegate_data['name'], delegate_data['user_id'][1]) - self.log(cr, uid, task.id, message) + self.do_close(cr, uid, [task.id], context=context) + self.case_delegation_send_note(cr, uid, [task.id], context) delegated_tasks[task.id] = delegated_task_id return delegated_tasks def do_pending(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'pending'}, context=context) - for (id, name) in self.name_get(cr, uid, ids): - message = _("The task '%s' is pending.") % name - self.log(cr, uid, id, message) + self.case_pending_send_note(cr, uid, ids, context) return True def set_remaining_time(self, cr, uid, ids, remaining_time=1.0, context=None): @@ -985,7 +981,7 @@ class task(osv.osv): def set_kanban_state_done(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'kanban_state': 'done'}, context=context) - def _change_type(self, cr, uid, ids, next, *args): + def _change_type(self, cr, uid, ids, next, context=None): """ go to the next stage if next is False, go to previous stage @@ -1006,13 +1002,14 @@ class task(osv.osv): elif typeid and typeid in sorted_types and sorted_types.index(typeid) != len(sorted_types)-1: index = sorted_types.index(typeid) self.write(cr, uid, task.id, {'type_id': sorted_types[index+1]}) + self.case_state_change_send_note(cr, uid, [task.id], context) return True - def next_type(self, cr, uid, ids, *args): - return self._change_type(cr, uid, ids, True, *args) + def next_type(self, cr, uid, ids, context=None): + return self._change_type(cr, uid, ids, True, context) - def prev_type(self, cr, uid, ids, *args): - return self._change_type(cr, uid, ids, False, *args) + def prev_type(self, cr, uid, ids, context=None): + return self._change_type(cr, uid, ids, False, context) def _store_history(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): @@ -1028,11 +1025,68 @@ class task(osv.osv): }, context=context) return True + def get_needaction_user_ids(self, cr, uid, ids, context=None): + result = dict.fromkeys(ids, []) + for obj in self.browse(cr, uid, ids, context=context): + if (obj.state == 'draft' and obj.user_id): + result[obj.id] = [obj.user_id.id] + return result + def create(self, cr, uid, vals, context=None): result = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [result], context=context) + self.create_send_note(cr, uid, [result], context=context) return result + def create_send_note(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if obj.user_id.id : + self.message_subscribe(cr, uid, ids, [obj.user_id.id], context=context) + obj.message_append_note('',_("Task has been created.")) + return True + + def case_pending_send_note(self, cr, uid, ids, context=None): + for id in ids: + msg = 'Task is now pending.' + self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + return True + + def case_open_send_note(self, cr, uid, ids, context=None): + for id in ids: + msg = 'Task has been opened.' + self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + return True + + def case_cancel_send_note(self, cr, uid, ids, context=None): + for id in ids: + msg = 'Task has been canceled.' + self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + return True + + def case_close_send_note(self, cr, uid, ids, context=None): + for id in ids: + msg = 'Task has been closed.' + self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + return True + + def case_draft_send_note(self, cr, uid, ids, context=None): + for id in ids: + msg = 'Task has been renewed.' + self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + return True + + def case_delegation_send_note(self, cr, uid, ids, context=None): + for task in self.browse(cr, uid, ids, context=context): + msg = 'Task has been delegated to %s.' % (task.user_id.name) + self.message_append_note(cr, uid, [task.id], 'System Notification', msg, context=context) + return True + + def case_state_change_send_note(self, cr, uid, ids, context=None): + for task in self.browse(cr, uid, ids, context=context): + msg = 'Stage changed to %s' % (task.type_id.name) + self.message_append_note(cr, uid, [task.id], 'System Notification', msg, context=context) + return True + # Overridden to reset the kanban_state to normal whenever # the stage (type_id) of the task changes. def write(self, cr, uid, ids, vals, context=None): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 3716187dedc..02291d28fe8 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -291,12 +291,6 @@ - - - - - - @@ -309,6 +303,7 @@ + From f48b95afc41b0d2f2be37bd1e7bfd547993846a0 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Fri, 16 Mar 2012 17:45:28 +0530 Subject: [PATCH 2/7] [FIX] Renamed methods from 'case_XXX_send_note' to 'do_XXX_send_note' an overwrite get_needaction_user_ids and message_get_subscribers methods. bzr revid: bth@tinyerp.com-20120316121528-8wtewywrek91i342 --- addons/project/project.py | 44 +++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 4d61245d868..ca3f63d2513 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -846,7 +846,7 @@ class task(osv.osv): if not task.date_end: vals.update({ 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}) self.write(cr, uid, [task.id],vals, context=context) - self.case_close_send_note(cr, uid, [task.id], context) + self.do_close_send_note(cr, uid, [task.id], context) return True def do_reopen(self, cr, uid, ids, context=None): @@ -866,7 +866,7 @@ class task(osv.osv): }, context=context) self.write(cr, uid, [task.id], {'state': 'open'}, context=context) - self.case_open_send_note(cr, uid, [task.id], context) + self.do_open_send_note(cr, uid, [task.id], context) return True def do_cancel(self, cr, uid, ids, context={}): @@ -885,8 +885,8 @@ class task(osv.osv): 'ref_doc1': 'project.task,%d' % task.id, 'ref_doc2': 'project.project,%d' % project.id, }, context=context) - self.case_cancel_send_note(cr, uid, [task.id], context) self.write(cr, uid, [task.id], {'state': 'cancelled', 'remaining_hours':0.0}, context=context) + self.do_cancel_send_note(cr, uid, [task.id], context) return True def do_open(self, cr, uid, ids, context={}): @@ -897,12 +897,12 @@ class task(osv.osv): if not t.date_start: data['date_start'] = time.strftime('%Y-%m-%d %H:%M:%S') self.write(cr, uid, [t.id], data, context=context) - self.case_open_send_note(cr, uid, [t.id], context) + self.do_open_send_note(cr, uid, [t.id], context) return True def do_draft(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'draft'}, context=context) - self.case_draft_send_note(cr, uid, ids, context) + self.do_draft_send_note(cr, uid, ids, context) return True @@ -944,13 +944,13 @@ class task(osv.osv): self.do_pending(cr, uid, [task.id], context=context) elif delegate_data['state'] == 'done': self.do_close(cr, uid, [task.id], context=context) - self.case_delegation_send_note(cr, uid, [task.id], context) + self.do_delegation_send_note(cr, uid, [task.id], context) delegated_tasks[task.id] = delegated_task_id return delegated_tasks def do_pending(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'pending'}, context=context) - self.case_pending_send_note(cr, uid, ids, context) + self.do_pending_send_note(cr, uid, ids, context) return True def set_remaining_time(self, cr, uid, ids, remaining_time=1.0, context=None): @@ -1002,7 +1002,7 @@ class task(osv.osv): elif typeid and typeid in sorted_types and sorted_types.index(typeid) != len(sorted_types)-1: index = sorted_types.index(typeid) self.write(cr, uid, task.id, {'type_id': sorted_types[index+1]}) - self.case_state_change_send_note(cr, uid, [task.id], context) + self.state_change_send_note(cr, uid, [task.id], context) return True def next_type(self, cr, uid, ids, context=None): @@ -1028,10 +1028,17 @@ class task(osv.osv): def get_needaction_user_ids(self, cr, uid, ids, context=None): result = dict.fromkeys(ids, []) for obj in self.browse(cr, uid, ids, context=context): - if (obj.state == 'draft' and obj.user_id): + if obj.state == 'draft' and obj.user_id: result[obj.id] = [obj.user_id.id] return result + def message_get_subscribers(self, cr, uid, ids, context=None): + sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context); + for obj in self.browse(cr, uid, ids, context=context): + if obj.user_id: + sub_ids.append(obj.user_id.id) + return self.pool.get('res.users').read(cr, uid, sub_ids, context=context) + def create(self, cr, uid, vals, context=None): result = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [result], context=context) @@ -1039,49 +1046,46 @@ class task(osv.osv): return result def create_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): - if obj.user_id.id : - self.message_subscribe(cr, uid, ids, [obj.user_id.id], context=context) - obj.message_append_note('',_("Task has been created.")) + self.message_append_note(cr, uid, ids, _('System notification'), _("Task has been created."), type='notification', context=context) return True - def case_pending_send_note(self, cr, uid, ids, context=None): + def do_pending_send_note(self, cr, uid, ids, context=None): for id in ids: msg = 'Task is now pending.' self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) return True - def case_open_send_note(self, cr, uid, ids, context=None): + def do_open_send_note(self, cr, uid, ids, context=None): for id in ids: msg = 'Task has been opened.' self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) return True - def case_cancel_send_note(self, cr, uid, ids, context=None): + def do_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = 'Task has been canceled.' self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) return True - def case_close_send_note(self, cr, uid, ids, context=None): + def do_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = 'Task has been closed.' self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) return True - def case_draft_send_note(self, cr, uid, ids, context=None): + def do_draft_send_note(self, cr, uid, ids, context=None): for id in ids: msg = 'Task has been renewed.' self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) return True - def case_delegation_send_note(self, cr, uid, ids, context=None): + def do_delegation_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): msg = 'Task has been delegated to %s.' % (task.user_id.name) self.message_append_note(cr, uid, [task.id], 'System Notification', msg, context=context) return True - def case_state_change_send_note(self, cr, uid, ids, context=None): + def state_change_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): msg = 'Stage changed to %s' % (task.type_id.name) self.message_append_note(cr, uid, [task.id], 'System Notification', msg, context=context) From 8f9489596bdafbd9ac87610f14ce6e9959e1362f Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Fri, 16 Mar 2012 18:22:57 +0530 Subject: [PATCH 3/7] [FIX] Remove For loop. bzr revid: bth@tinyerp.com-20120316125257-blyd6clm1m24rzbd --- addons/project/project.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index ca3f63d2513..102900ee9a9 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1050,33 +1050,28 @@ class task(osv.osv): return True def do_pending_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = 'Task is now pending.' - self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + msg = 'Task is now pending.' + self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) return True def do_open_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = 'Task has been opened.' - self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + msg = 'Task has been opened.' + self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) return True def do_cancel_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = 'Task has been canceled.' - self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + msg = 'Task has been canceled.' + self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) return True def do_close_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = 'Task has been closed.' - self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + msg = 'Task has been closed.' + self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = 'Task has been renewed.' - self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context) + msg = 'Task has been renewed.' + self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) return True def do_delegation_send_note(self, cr, uid, ids, context=None): From 6c3ac4453ecae2745580a26498fc812b28e0f5dc Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Tue, 20 Mar 2012 17:13:01 +0530 Subject: [PATCH 4/7] [FIX] if not list then assign list value. bzr revid: bth@tinyerp.com-20120320114301-j0nxo25x290i0kgh --- addons/project/project.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/project/project.py b/addons/project/project.py index 102900ee9a9..8578ac3cc62 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1050,6 +1050,7 @@ class task(osv.osv): return True def do_pending_send_note(self, cr, uid, ids, context=None): + if not isinstance(ids,list): ids = [ids] msg = 'Task is now pending.' self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) return True From 4bd907e30380f1e0d3700399d734ab9da4bc35de Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Wed, 21 Mar 2012 11:25:49 +0530 Subject: [PATCH 5/7] [IMP] Project manager is added in subscribers. bzr revid: bth@tinyerp.com-20120321055549-f0ng25r5k97ekblc --- addons/project/project.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 8578ac3cc62..298e6941a95 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1037,8 +1037,11 @@ class task(osv.osv): for obj in self.browse(cr, uid, ids, context=context): if obj.user_id: sub_ids.append(obj.user_id.id) + if obj.manager_id: + sub_ids.append(obj.manager_id.id) return self.pool.get('res.users').read(cr, uid, sub_ids, context=context) + def create(self, cr, uid, vals, context=None): result = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [result], context=context) From 72961b7fcf826161d02d736357d6dae4eef762cd Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Mon, 2 Apr 2012 18:56:35 +0530 Subject: [PATCH 6/7] [IMP] state changed in kanban view of task then notification is came on task. bzr revid: bth@tinyerp.com-20120402132635-wuynl1jl92mffzgd --- addons/project/project.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/project/project.py b/addons/project/project.py index 2254dd28383..6118c51fe98 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1105,6 +1105,7 @@ class task(osv.osv): result = super(task,self).write(cr, uid, ids, vals, context=context) if ('type_id' in vals) or ('remaining_hours' in vals) or ('user_id' in vals) or ('state' in vals) or ('kanban_state' in vals): self._store_history(cr, uid, ids, context=context) + self.state_change_send_note(cr, uid, ids, context) return result def unlink(self, cr, uid, ids, context=None): From 86d96e7aa2841af2ac986f869cd5ee49bc5f0d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 3 Apr 2012 10:38:15 +0200 Subject: [PATCH 7/7] =?UTF-8?q?[CLEAN]=C2=B8Cleaned=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bzr revid: tde@openerp.com-20120403083815-83z7f9s1orj2ogeu --- addons/project/project.py | 129 +++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 66 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 6118c51fe98..82f1ed4c70e 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -456,7 +456,7 @@ class task(osv.osv): _description = "Task" _log_create = True _date_name = "date_start" - _inherit = ['mail.thread'] + _inherit = ['ir.needaction', 'mail.thread'] def _resolve_project_id_from_context(self, cr, uid, context=None): @@ -1005,10 +1005,10 @@ class task(osv.osv): return True def next_type(self, cr, uid, ids, context=None): - return self._change_type(cr, uid, ids, True, context) + return self._change_type(cr, uid, ids, True, context=context) def prev_type(self, cr, uid, ids, context=None): - return self._change_type(cr, uid, ids, False, context) + return self._change_type(cr, uid, ids, False, context=context) def _store_history(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): @@ -1024,70 +1024,11 @@ class task(osv.osv): }, context=context) return True - def get_needaction_user_ids(self, cr, uid, ids, context=None): - result = dict.fromkeys(ids, []) - for obj in self.browse(cr, uid, ids, context=context): - if obj.state == 'draft' and obj.user_id: - result[obj.id] = [obj.user_id.id] - return result - - def message_get_subscribers(self, cr, uid, ids, context=None): - sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context); - for obj in self.browse(cr, uid, ids, context=context): - if obj.user_id: - sub_ids.append(obj.user_id.id) - if obj.manager_id: - sub_ids.append(obj.manager_id.id) - return self.pool.get('res.users').read(cr, uid, sub_ids, context=context) - - def create(self, cr, uid, vals, context=None): - result = super(task, self).create(cr, uid, vals, context=context) - self._store_history(cr, uid, [result], context=context) - self.create_send_note(cr, uid, [result], context=context) - return result - - def create_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, _('System notification'), _("Task has been created."), type='notification', context=context) - return True - - def do_pending_send_note(self, cr, uid, ids, context=None): - if not isinstance(ids,list): ids = [ids] - msg = 'Task is now pending.' - self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) - return True - - def do_open_send_note(self, cr, uid, ids, context=None): - msg = 'Task has been opened.' - self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) - return True - - def do_cancel_send_note(self, cr, uid, ids, context=None): - msg = 'Task has been canceled.' - self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) - return True - - def do_close_send_note(self, cr, uid, ids, context=None): - msg = 'Task has been closed.' - self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) - return True - - def do_draft_send_note(self, cr, uid, ids, context=None): - msg = 'Task has been renewed.' - self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context) - return True - - def do_delegation_send_note(self, cr, uid, ids, context=None): - for task in self.browse(cr, uid, ids, context=context): - msg = 'Task has been delegated to %s.' % (task.user_id.name) - self.message_append_note(cr, uid, [task.id], 'System Notification', msg, context=context) - return True - - def state_change_send_note(self, cr, uid, ids, context=None): - for task in self.browse(cr, uid, ids, context=context): - msg = 'Stage changed to %s' % (task.type_id.name) - self.message_append_note(cr, uid, [task.id], 'System Notification', msg, context=context) - return True + task_id = super(task, self).create(cr, uid, vals, context=context) + self._store_history(cr, uid, [task_id], context=context) + self.create_send_note(cr, uid, [task_id], context=context) + return task_id # Overridden to reset the kanban_state to normal whenever # the stage (type_id) of the task changes. @@ -1141,6 +1082,62 @@ class task(osv.osv): result += "\n" return result + + # --------------------------------------------------- + # OpenChatter methods and notifications + # --------------------------------------------------- + + def get_needaction_user_ids(self, cr, uid, ids, context=None): + result = dict.fromkeys(ids, []) + for obj in self.browse(cr, uid, ids, context=context): + if obj.state == 'draft' and obj.user_id: + result[obj.id] = [obj.user_id.id] + return result + + def message_get_subscribers(self, cr, uid, ids, context=None): + sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context); + for obj in self.browse(cr, uid, ids, context=context): + if obj.user_id: + sub_ids.append(obj.user_id.id) + if obj.manager_id: + sub_ids.append(obj.manager_id.id) + return self.pool.get('res.users').read(cr, uid, sub_ids, context=context) + + def create_send_note(self, cr, uid, ids, context=None): + return self.message_append_note(cr, uid, ids, body=_("Task has been created."), context=context) + + def do_pending_send_note(self, cr, uid, ids, context=None): + if not isinstance(ids,list): ids = [ids] + msg = _('Task is now pending.') + return self.message_append_note(cr, uid, ids, body=msg, context=context) + + def do_open_send_note(self, cr, uid, ids, context=None): + msg = _('Task has been opened.') + return self.message_append_note(cr, uid, ids, body=msg, context=context) + + def do_cancel_send_note(self, cr, uid, ids, context=None): + msg = _('Task has been canceled.') + return self.message_append_note(cr, uid, ids, body=msg, context=context) + + def do_close_send_note(self, cr, uid, ids, context=None): + msg = _('Task has been closed.') + return self.message_append_note(cr, uid, ids, body=msg, context=context) + + def do_draft_send_note(self, cr, uid, ids, context=None): + msg = _('Task has been renewed.') + return self.message_append_note(cr, uid, ids, body=msg, context=context) + + def do_delegation_send_note(self, cr, uid, ids, context=None): + for task in self.browse(cr, uid, ids, context=context): + msg = _('Task has been delegated to %s.') % (task.user_id.name) + self.message_append_note(cr, uid, [task.id], body=msg, context=context) + return True + + def state_change_send_note(self, cr, uid, ids, context=None): + for task in self.browse(cr, uid, ids, context=context): + msg = _('Stage changed to %s') % (task.type_id.name) + self.message_append_note(cr, uid, [task.id], body=msg, context=context) + return True task()