From 5eebf54a7528b4141980c4a6af225457cf520cac Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Tue, 20 Mar 2012 17:17:28 +0530 Subject: [PATCH] [IMP] Renamed methods and modify code for loops and overwrite get_needaction_user_ids and message_get_subscribers. bzr revid: bth@tinyerp.com-20120320114728-6awxltk66d3cykzg --- addons/project_issue/project_issue.py | 53 +++++++++++++++------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 2d47e245767..759e19d81e7 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -363,34 +363,40 @@ class project_issue(crm.crm_case, osv.osv): return {'value':{'user_id': task.user_id.id,}} def case_open_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): + for id in ids: message = _("has been opened.") - obj.message_append_note('' ,message) + self.message_append_note(cr, uid, [id],'System Notification', message, context=context) return True def case_close_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): + for id in ids: message = _("has been closed.") - obj.message_append_note('' ,message) + self.message_append_note(cr, uid, [id],'System Notification', message, context=context) return True def convert_to_task_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, ids, _('System notification'), - _("has been converted in to task."), type='notification', context=context) + for id in ids: + message = _("has been converted in to task.") + self.message_append_note(cr, uid, [id], 'System notification', message, context=context) return True - def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None): - result = {} + 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): - result[obj.id] = False - if (obj.state == 'draft' and obj.user_id): - result[obj.id] = obj.user_id.id + if obj.state == 'draft' and obj.user_id: + result[obj.id] = [obj.user_id.id] if obj.project_id.user_id: - result[obj.id] = obj.project_id.user_id.id + result[obj.id] = [obj.project_id.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 case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): if obj.project_id: @@ -401,30 +407,29 @@ class project_issue(crm.crm_case, osv.osv): obj.message_append_note('' ,message, type='notification', context=context) return True - def case_create_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): -# self.message_subscribe(cr, uid, ids, [obj.user_id.id], context=context) + def create_send_note(self, cr, uid, ids, context=None): + for id in ids: message = _("has been created.") - self.message_append_note(cr, uid, ids, _('System notification'), + self.message_append_note(cr, uid, [id], _('System notification'), message, type='notification', context=context) return True def case_pending_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): + for id in ids: message = _("has been pending.") - obj.message_append_note('' ,message) + self.message_append_note(cr, uid, [id], 'System Notification', message, context=context) return True def case_reset_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): + for id in ids: message =_("has been set as new.") - obj.message_append_note('' ,message) + self.message_append_note(cr, uid, [id],'System Notification', message, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): + for id in ids: message = _("has been cancelled.") - obj.message_append_note('' ,message) + self.message_append_note(cr, uid, [id],'System Notification', message, context=context) return True def case_reset(self, cr, uid, ids, context=None): @@ -450,7 +455,7 @@ class project_issue(crm.crm_case, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(project_issue, self).create(cr, uid, vals, context=context) - self.case_create_send_note(cr, uid, [obj_id], context=context) + self.create_send_note(cr, uid, [obj_id], context=context) return obj_id def case_open(self, cr, uid, ids, context=None):