From 0688cc33a2b0164892b27f1999c4efe8ba7dabfe Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Wed, 29 Feb 2012 17:33:55 +0530 Subject: [PATCH 01/13] [FIX] Remove subject from stage change notification. bzr revid: bth@tinyerp.com-20120229120355-4rnh98lsssrd96l7 --- addons/crm/crm_lead.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 18f746880ca..50aa8dfff06 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -905,15 +905,13 @@ class crm_lead(crm_case, osv.osv): # change probability of lead(s) if required by stage if not vals.get('probability') and stage.on_change: vals['probability'] = stage.probability - text = _("Changed Stage to: %s") % stage.name - for case in self.browse(cr, uid, ids, context=context): if case.type == 'lead' or context.get('stage_type') == 'lead': message = _("The stage of lead has been changed to %s.") % (stage.name) - case.message_append_note(text, message) + case.message_append_note('', message) elif case.type == 'opportunity': message = _("The stage of opportunity has been changed to %s.") % (stage.name) - case.message_append_note(text, message) + case.message_append_note('', message) return super(crm_lead,self).write(cr, uid, ids, vals, context) From da087c47b0c7cea83a78fefb16c9cffb9dace1f1 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Tue, 6 Mar 2012 14:48:55 +0530 Subject: [PATCH 02/13] [IMP] notification for crm meeting and crm phonecall. bzr revid: bth@tinyerp.com-20120306091855-b7kx0wxxcu81uw0d --- addons/crm/crm.py | 5 ++++ addons/crm/crm_lead.py | 7 ++++++ addons/crm/crm_meeting.py | 34 +++++++++++++++++++++------ addons/crm/crm_meeting_view.xml | 1 + addons/crm/crm_phonecall.py | 39 ++++++++++++++++++++++++++----- addons/crm/crm_phonecall_view.xml | 1 + 6 files changed, 74 insertions(+), 13 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index fdcd7a1a52a..4f2d2a120d8 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -273,6 +273,9 @@ class crm_base(object): def _case_pending_notification(self, case, context=None): return True + def _case_reset_notification(self, case, context=None): + return True + def _case_escalate_notification(self, case, context=None): return True @@ -336,6 +339,7 @@ class crm_base(object): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'draft', 'active': True}) + self._case_reset_notification(cases, context=context) self._action(cr, uid, cases, 'draft') return True @@ -485,6 +489,7 @@ class crm_case(crm_base): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': state, 'active': True}) + self._case_reset_notification(cases, context=context); self._action(cr, uid, cases, state) return True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 50aa8dfff06..ed9cce87a8e 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -334,6 +334,13 @@ class crm_lead(crm_case, osv.osv): message = _("The lead is escalated.") case.message_append_note('' ,message) + def _case_reset_notification(self, case, context=None): + if case[0].type == 'lead': + message = _("The lead is renewed.") + elif case[0].type == 'opportunity': + message = _("The opportunity is renewed.") + case[0].message_append_note('' ,message, need_action_user_id=case[0].user_id.id) + def _case_phonecall_notification(self, cr, uid, ids, case, phonecall, action, context=None): for obj in phonecall.browse(cr, uid, ids, context=context): if action == "schedule" : diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 5ba93d526af..10635d66a6c 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -42,7 +42,7 @@ class crm_meeting(crm_base, osv.osv): _name = 'crm.meeting' _description = "Meeting" _order = "id desc" - _inherit = "calendar.event" + _inherit = ["calendar.event","mail.thread"] _columns = { # From crm.case 'name': fields.char('Summary', size=124, required=True, states={'done': [('readonly', True)]}), @@ -87,15 +87,37 @@ class crm_meeting(crm_base, osv.osv): def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None): lead_obj = self.pool.get('crm.lead') - + phonecall_obj = self.pool.get('crm.phonecall') for obj in self.browse(cr, uid, ids, context=context): if(obj.opportunity_id.id): newid = obj.opportunity_id.id - message = _("scheduled for meeting %s.") % (obj.date) + message = _("scheduled meeting on %s for opportunity.") % (obj.date) for lead in lead_obj.browse(cr, uid, [newid], context=context): lead.message_append_note('', message) + obj.message_append_note('', message, need_action_user_id=lead.user_id.id) + elif(obj.phonecall_id.id): + newid = obj.phonecall_id.id + message = _("scheduled meeting on %s for phonecall.") % (obj.date) + for phonecall in phonecall_obj.browse(cr, uid, [newid], context=context): + phonecall.message_append_note('', message) + obj.message_append_note('', message, need_action_user_id=phonecall.user_id.id) - def case_open(self, cr, uid, ids, *args): + def _case_close_notification(self, meeting, context=None): + meeting[0].message_mark_done(context) + message = _("The meeting is done.") + meeting[0].message_append_note('' ,message) + + def _case_reset_notification(self, meeting, context=None): + message = _("The meeting is unconfirmed.") + meeting[0].message_append_note('' ,message) + + def _case_open_notification(self, meeting, context=None): + if meeting.state != 'draft': + return False + message = _("The meeting has been confirmed.") + meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id) + + def case_open(self, cr, uid, ids, context=None): """Confirms meeting @param self: The object pointer @param cr: the current row, from the database cursor, @@ -103,11 +125,9 @@ class crm_meeting(crm_base, osv.osv): @param ids: List of Meeting Ids @param *args: Tuple Value for additional Params """ - res = super(crm_meeting, self).case_open(cr, uid, ids, args) + res = super(crm_meeting, self).case_open(cr, uid, ids, context) for (id, name) in self.name_get(cr, uid, ids): - message = _("The meeting '%s' has been confirmed.") % name id=base_calendar.base_calendar_id2real_id(id) - self.log(cr, uid, id, message) return res crm_meeting() diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index 527f5814be4..cd0b6240d41 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -216,6 +216,7 @@ + diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index 4063157aed9..d7d52120652 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -80,6 +80,7 @@ class crm_phonecall(crm_base, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_phonecall, self).create(cr, uid, vals, context=context) + self.open_notification(cr, uid, [obj_id], context) return obj_id def _get_default_state(self, cr, uid, context=None): @@ -94,6 +95,29 @@ class crm_phonecall(crm_base, osv.osv): 'user_id': lambda self,cr,uid,ctx: uid, 'active': 1, } + def _case_cancel_notification(self, phonecall, context=None): + phonecall[0].message_mark_done(context) + message = _("The Phonecall is cancelled.") + phonecall[0].message_append_note( _('System notification'), + message, type='notification', context=context) + + def _case_pending_notification(self, phonecall, context=None): + message = _("The Phonecall is pending.") + phonecall[0].message_append_note('' ,message) + + def done_notification(self, cr, uid, ids, context=None): + for phonecall in self.browse(cr, uid, ids): + phonecall.message_mark_done(context) + message = _("The Phonecall is done.") + self.message_append_note(cr, uid, [phonecall.id], _('System notification'), + message, type='notification', context=context) + + def open_notification(self, cr, uid, ids, context=None): + for phonecall in self.browse(cr, uid, ids): + self.message_subscribe(cr, uid, ids, [phonecall.user_id.id], context=context) + message = _("The Phonecall is open.") + self.message_append_note(cr, uid, [phonecall.id], _('System notification'),message, + type='notification', need_action_user_id=phonecall.user_id.id, context=context) # From crm.case def onchange_partner_address_id(self, cr, uid, ids, add, email=False): @@ -105,7 +129,7 @@ class crm_phonecall(crm_base, osv.osv): res['value']['partner_mobile'] = address.mobile return res - def case_close(self, cr, uid, ids, *args): + def case_close(self, cr, uid, ids, context=None): """Overrides close for crm_case for setting close date """ res = True @@ -115,23 +139,26 @@ class crm_phonecall(crm_base, osv.osv): if phone.duration <=0: duration = datetime.now() - datetime.strptime(phone.date, '%Y-%m-%d %H:%M:%S') data.update({'duration': duration.seconds/float(60)}) - res = super(crm_phonecall, self).case_close(cr, uid, [phone_id], args) + res = super(crm_phonecall, self).case_close(cr, uid, [phone_id], context) self.write(cr, uid, [phone_id], data) + self.done_notification(cr, uid, [phone_id], context); return res - def case_reset(self, cr, uid, ids, *args): + def case_reset(self, cr, uid, ids, context=None): """Resets case as Todo """ - res = super(crm_phonecall, self).case_reset(cr, uid, ids, args) + res = super(crm_phonecall, self).case_reset(cr, uid, ids, context) self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'}) + self.open_notification(cr, uid, ids, context) return res - def case_open(self, cr, uid, ids, *args): + def case_open(self, cr, uid, ids, context=None): """Overrides cancel for crm_case for setting Open Date """ - res = super(crm_phonecall, self).case_open(cr, uid, ids, *args) + res = super(crm_phonecall, self).case_open(cr, uid, ids, context) self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) + self.open_notification(cr, uid, ids, context) return res def schedule_another_phonecall(self, cr, uid, ids, schedule_time, call_summary, \ diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index 34ef2612623..6bebccdaf6f 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -123,6 +123,7 @@ states="cancel" type="object" icon="gtk-convert" /> + From b0d0b176abae6da2efa6c77e769cf6e05c532815 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Tue, 6 Mar 2012 15:53:43 +0530 Subject: [PATCH 03/13] [IMP] on create meeting notification. bzr revid: bth@tinyerp.com-20120306102343-h32fhvuzfpuynjtl --- addons/crm/crm_meeting.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 10635d66a6c..0261612c32d 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -101,6 +101,9 @@ class crm_meeting(crm_base, osv.osv): for phonecall in phonecall_obj.browse(cr, uid, [newid], context=context): phonecall.message_append_note('', message) obj.message_append_note('', message, need_action_user_id=phonecall.user_id.id) + else: + message = _("scheduled meeting on %s.") % (obj.date) + obj.message_append_note('', message, need_action_user_id=obj.user_id.id) def _case_close_notification(self, meeting, context=None): meeting[0].message_mark_done(context) From d9dca412cc661d129dd1651b55859c64b02a65b2 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Tue, 6 Mar 2012 16:20:17 +0530 Subject: [PATCH 04/13] [FIX] changes in reset functions. bzr revid: bth@tinyerp.com-20120306105017-w2znwg19b713v1cb --- addons/crm/crm.py | 6 +++--- addons/crm/crm_lead.py | 15 ++++++++------- addons/crm/crm_meeting.py | 7 ++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 4f2d2a120d8..b504ae70e10 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -273,7 +273,7 @@ class crm_base(object): def _case_pending_notification(self, case, context=None): return True - def _case_reset_notification(self, case, context=None): + def _case_reset_notification(self, cr, uid, ids, context=None): return True def _case_escalate_notification(self, case, context=None): @@ -339,7 +339,7 @@ class crm_base(object): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'draft', 'active': True}) - self._case_reset_notification(cases, context=context) + self._case_reset_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'draft') return True @@ -489,7 +489,7 @@ class crm_case(crm_base): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': state, 'active': True}) - self._case_reset_notification(cases, context=context); + self._case_reset_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, state) return True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index ed9cce87a8e..46c643d6bc4 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -271,6 +271,14 @@ class crm_lead(crm_case, osv.osv): def stage_find_won(self, cr, uid, section_id): return self.stage_find_percent(cr, uid, 100.0, section_id) + def _case_reset_notification(self, cr, uid, ids, context=None): + for lead in self.browse(cr, uid, ids, context=context): + if lead.type == 'lead': + message = _("The lead is renewed.") + elif lead.type == 'opportunity': + message = _("The opportunity is renewed.") + lead.message_append_note('' ,message, need_action_user_id=lead.user_id.id) + def _case_create_notification(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) @@ -334,13 +342,6 @@ class crm_lead(crm_case, osv.osv): message = _("The lead is escalated.") case.message_append_note('' ,message) - def _case_reset_notification(self, case, context=None): - if case[0].type == 'lead': - message = _("The lead is renewed.") - elif case[0].type == 'opportunity': - message = _("The opportunity is renewed.") - case[0].message_append_note('' ,message, need_action_user_id=case[0].user_id.id) - def _case_phonecall_notification(self, cr, uid, ids, case, phonecall, action, context=None): for obj in phonecall.browse(cr, uid, ids, context=context): if action == "schedule" : diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 0261612c32d..22586c7b4fb 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -110,9 +110,10 @@ class crm_meeting(crm_base, osv.osv): message = _("The meeting is done.") meeting[0].message_append_note('' ,message) - def _case_reset_notification(self, meeting, context=None): - message = _("The meeting is unconfirmed.") - meeting[0].message_append_note('' ,message) + def _case_reset_notification(self, cr, uid, ids, context=None): + for meeting in self.browse(cr, uid, ids, context=context): + message = _("The lead is renew.") + meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id) def _case_open_notification(self, meeting, context=None): if meeting.state != 'draft': From 821b3a773a0e2537c904ce6e253378401d47d8b4 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Tue, 6 Mar 2012 18:58:48 +0530 Subject: [PATCH 05/13] [FIX] minor changes for call reset notification function. bzr revid: bth@tinyerp.com-20120306132848-1jskbzll692kn2bs --- addons/crm/crm.py | 1 - addons/crm/crm_lead.py | 1 + addons/crm/crm_meeting.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index b504ae70e10..3aee3ec463a 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -489,7 +489,6 @@ class crm_case(crm_base): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': state, 'active': True}) - self._case_reset_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, state) return True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 46c643d6bc4..62199f7ad15 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -380,6 +380,7 @@ class crm_lead(crm_case, osv.osv): """ res = super(crm_lead, self).case_reset(cr, uid, ids, context) self.write(cr, uid, ids, {'stage_id': False, 'probability': 0.0}) + self._case_reset_notification(cr, uid, ids, context=context) return res def case_mark_lost(self, cr, uid, ids, context=None): diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 22586c7b4fb..47117a82fc1 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -112,7 +112,7 @@ class crm_meeting(crm_base, osv.osv): def _case_reset_notification(self, cr, uid, ids, context=None): for meeting in self.browse(cr, uid, ids, context=context): - message = _("The lead is renew.") + message = _("The meeting is renewed.") meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id) def _case_open_notification(self, meeting, context=None): From 18c91886e4417569d2c0d143e0da4248ed06f30e Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Wed, 7 Mar 2012 16:43:16 +0530 Subject: [PATCH 06/13] [FIX]Notification messages modified. bzr revid: bth@tinyerp.com-20120307111316-4ac06gjd5o2ixcmp --- addons/crm/crm_lead.py | 39 +++++++++++++++++-------------------- addons/crm/crm_meeting.py | 12 ++++++------ addons/crm/crm_phonecall.py | 26 +++++++++---------------- 3 files changed, 33 insertions(+), 44 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 62199f7ad15..a5c3792b33f 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -274,9 +274,9 @@ class crm_lead(crm_case, osv.osv): def _case_reset_notification(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): if lead.type == 'lead': - message = _("The lead is renewed.") + message = _("Lead is renewed.") elif lead.type == 'opportunity': - message = _("The opportunity is renewed.") + message = _("Opportunity is renewed.") lead.message_append_note('' ,message, need_action_user_id=lead.user_id.id) def _case_create_notification(self, cr, uid, ids, context=None): @@ -287,7 +287,7 @@ class crm_lead(crm_case, osv.osv): elif obj.type=="lead" : message = _("Lead is created.") else: - message = _("The case has been created.") + message = _("Case is created.") self.message_append_note(cr, uid, ids, _('System notification'), message, type='notification', need_action_user_id=obj.user_id.id, context=context) return True @@ -296,50 +296,50 @@ class crm_lead(crm_case, osv.osv): if lead.state != 'draft' and lead.state != 'pending': return False if lead.type == 'lead': - message = _("The lead has been opened.") + message = _("Lead is opened.") elif lead.type == 'opportunity': - message = _("The opportunity has been opened.") + message = _("Opportunity is opened.") else: - message = _("The case has been opened.") + message = _("Case is opened.") lead.message_append_note('' ,message, need_action_user_id=lead.user_id.id) def _case_close_notification(self, lead, context=None): lead[0].message_mark_done(context) if lead[0].type == 'lead': - message = _("The lead has been closed.") + message = _("Lead is closed.") elif lead[0].type == 'opportunity': - message = _("The opportunity has been closed.") + message = _("Opportunity is closed.") else: - message = _("The case has been closed.") + message = _("Case is closed.") lead[0].message_append_note('' ,message) def _case_mark_lost_notification(self, lead, context=None): lead.message_mark_done(context) - message = _("The opportunity has been marked as lost.") + message = _("Opportunity is marked as lost.") lead.message_append_note('' ,message) def _case_mark_won_notification(self, lead, context=None): lead.message_mark_done(context) - message = _("The opportunity has been won.") + message = _("Opportunity is won.") lead.message_append_note('' ,message) def _case_cancel_notification(self, lead, context=None): lead[0].message_mark_done(context) if lead[0].type == 'lead': - message = _("The lead has been cancelled.") + message = _("Lead is cancelled.") elif lead[0].type == 'opportunity': - message = _("The opportunity has been cancelled.") + message = _("Opportunity is cancelled.") lead[0].message_append_note('' ,message) def _case_pending_notification(self, case, context=None): if case[0].type == 'lead': - message = _("The lead is pending.") + message = _("Lead is pending.") elif case[0].type == 'opportunity': - message = _("The opportunity is pending.") + message = _("Opportunity is pending.") case[0].message_append_note('' ,message) def _case_escalate_notification(self, case, context=None): - message = _("The lead is escalated.") + message = _("Lead is escalated.") case.message_append_note('' ,message) def _case_phonecall_notification(self, cr, uid, ids, case, phonecall, action, context=None): @@ -349,8 +349,6 @@ class crm_lead(crm_case, osv.osv): else : message = _("%s a call.") % (action) case.message_append_note('', message) - if action == "schedule" : - phonecall.message_append_note(cr, uid, ids, '', message, need_action_user_id=obj.user_id.id) def case_open(self, cr, uid, ids, context=None): res = super(crm_lead, self).case_open(cr, uid, ids, context) @@ -766,7 +764,6 @@ class crm_lead(crm_case, osv.osv): 'partner_mobile' : lead.partner_address_id and lead.partner_address_id.mobile or False, 'priority': lead.priority, } - new_id = phonecall.create(cr, uid, vals, context=context) phonecall.case_open(cr, uid, [new_id]) if action == 'log': @@ -916,10 +913,10 @@ class crm_lead(crm_case, osv.osv): vals['probability'] = stage.probability for case in self.browse(cr, uid, ids, context=context): if case.type == 'lead' or context.get('stage_type') == 'lead': - message = _("The stage of lead has been changed to %s.") % (stage.name) + message = _("Changed to %s.") % (stage.name) case.message_append_note('', message) elif case.type == 'opportunity': - message = _("The stage of opportunity has been changed to %s.") % (stage.name) + message = _("Changed to %s.") % (stage.name) case.message_append_note('', message) return super(crm_lead,self).write(cr, uid, ids, vals, context) diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 47117a82fc1..3bec7988ba5 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -91,34 +91,34 @@ class crm_meeting(crm_base, osv.osv): for obj in self.browse(cr, uid, ids, context=context): if(obj.opportunity_id.id): newid = obj.opportunity_id.id - message = _("scheduled meeting on %s for opportunity.") % (obj.date) + message = _("Meeting is scheduled on %s for opportunity.") % (obj.date) for lead in lead_obj.browse(cr, uid, [newid], context=context): lead.message_append_note('', message) obj.message_append_note('', message, need_action_user_id=lead.user_id.id) elif(obj.phonecall_id.id): newid = obj.phonecall_id.id - message = _("scheduled meeting on %s for phonecall.") % (obj.date) + message = _("Meeting is scheduled on %s for phonecall.") % (obj.date) for phonecall in phonecall_obj.browse(cr, uid, [newid], context=context): phonecall.message_append_note('', message) obj.message_append_note('', message, need_action_user_id=phonecall.user_id.id) else: - message = _("scheduled meeting on %s.") % (obj.date) + message = _("Meeting is scheduled on %s .") % (obj.date) obj.message_append_note('', message, need_action_user_id=obj.user_id.id) def _case_close_notification(self, meeting, context=None): meeting[0].message_mark_done(context) - message = _("The meeting is done.") + message = _("Meeting is done.") meeting[0].message_append_note('' ,message) def _case_reset_notification(self, cr, uid, ids, context=None): for meeting in self.browse(cr, uid, ids, context=context): - message = _("The meeting is renewed.") + message = _("Meeting is renewed.") meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id) def _case_open_notification(self, meeting, context=None): if meeting.state != 'draft': return False - message = _("The meeting has been confirmed.") + message = _("Meeting is confirmed.") meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id) def case_open(self, cr, uid, ids, context=None): diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index d7d52120652..74315786745 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -78,11 +78,6 @@ class crm_phonecall(crm_base, osv.osv): 'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', domain=[('model','=',_name)]), } - def create(self, cr, uid, vals, context=None): - obj_id = super(crm_phonecall, self).create(cr, uid, vals, context=context) - self.open_notification(cr, uid, [obj_id], context) - return obj_id - def _get_default_state(self, cr, uid, context=None): if context and context.get('default_state', False): return context.get('default_state') @@ -97,27 +92,25 @@ class crm_phonecall(crm_base, osv.osv): } def _case_cancel_notification(self, phonecall, context=None): phonecall[0].message_mark_done(context) - message = _("The Phonecall is cancelled.") + message = _("Phonecall is cancelled.") phonecall[0].message_append_note( _('System notification'), message, type='notification', context=context) def _case_pending_notification(self, phonecall, context=None): - message = _("The Phonecall is pending.") + message = _("Phonecall is pending.") phonecall[0].message_append_note('' ,message) def done_notification(self, cr, uid, ids, context=None): for phonecall in self.browse(cr, uid, ids): phonecall.message_mark_done(context) - message = _("The Phonecall is done.") + message = _("Phonecall is done.") self.message_append_note(cr, uid, [phonecall.id], _('System notification'), message, type='notification', context=context) - def open_notification(self, cr, uid, ids, context=None): - for phonecall in self.browse(cr, uid, ids): - self.message_subscribe(cr, uid, ids, [phonecall.user_id.id], context=context) - message = _("The Phonecall is open.") - self.message_append_note(cr, uid, [phonecall.id], _('System notification'),message, - type='notification', need_action_user_id=phonecall.user_id.id, context=context) + def _case_open_notification(self, phonecall, context=None): + phonecall.message_subscribe([phonecall.user_id.id], context=context) + message = _("Phonecall is opened.") + phonecall.message_append_note('' ,message, need_action_user_id=phonecall.user_id.id) # From crm.case def onchange_partner_address_id(self, cr, uid, ids, add, email=False): @@ -149,7 +142,8 @@ class crm_phonecall(crm_base, osv.osv): """ res = super(crm_phonecall, self).case_reset(cr, uid, ids, context) self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'}) - self.open_notification(cr, uid, ids, context) + for phone in self.browse(cr, uid, ids): + self._case_open_notification(phone, context=context) return res @@ -158,7 +152,6 @@ class crm_phonecall(crm_base, osv.osv): """ res = super(crm_phonecall, self).case_open(cr, uid, ids, context) self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) - self.open_notification(cr, uid, ids, context) return res def schedule_another_phonecall(self, cr, uid, ids, schedule_time, call_summary, \ @@ -190,7 +183,6 @@ class crm_phonecall(crm_base, osv.osv): 'partner_mobile' : call.partner_mobile, 'priority': call.priority, } - new_id = self.create(cr, uid, vals, context=context) self.case_open(cr, uid, [new_id]) if action == 'log': From a84575e440ed2c62afd824b879cf4d97137fc261 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Wed, 7 Mar 2012 17:46:34 +0530 Subject: [PATCH 07/13] [IMP] notification for creating partner for lead or opportunity. bzr revid: bth@tinyerp.com-20120307121634-m6nyj3i68pgzb3t9 --- addons/crm/crm_lead.py | 9 ++++++++- addons/crm/crm_lead_view.xml | 4 ++-- addons/crm/crm_meeting_view.xml | 2 +- addons/crm/crm_phonecall_view.xml | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index a5c3792b33f..46174c6ab67 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -350,6 +350,13 @@ class crm_lead(crm_case, osv.osv): message = _("%s a call.") % (action) case.message_append_note('', message) + def _case_partner_notification(self, lead, context=None): + if lead.type == 'lead': + message = _("Partner is created for this lead.") + elif lead.type == 'opportunity': + message = _("Partner is created for this opportunity.") + lead.message_append_note('' ,message) + def case_open(self, cr, uid, ids, context=None): res = super(crm_lead, self).case_open(cr, uid, ids, context) for lead in self.browse(cr, uid, ids, context=context): @@ -663,7 +670,7 @@ class crm_lead(crm_case, osv.osv): res_partner.write(cr, uid, partner_id, {'section_id': lead.section_id.id or False}) contact_id = res_partner.address_get(cr, uid, [partner_id])['default'] res = lead.write({'partner_id' : partner_id, 'partner_address_id': contact_id}, context=context) - + self._case_partner_notification(lead,context) return res def _lead_create_partner_address(self, cr, uid, lead, partner_id, context=None): diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 185f9f55ef8..d27b24727a0 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -168,7 +168,7 @@ - + @@ -537,7 +537,7 @@ - + diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index cd0b6240d41..353a2ea7f94 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -216,7 +216,7 @@ - + diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index 6bebccdaf6f..d00c41bf73f 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -123,7 +123,7 @@ states="cancel" type="object" icon="gtk-convert" /> - + From b57da53738fd3e000427c15e662a010e6e128a74 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Fri, 9 Mar 2012 16:46:44 +0530 Subject: [PATCH 08/13] [IMP] removed need_action_user_id from message_append_note function when calling and overwrite get_needaction_user_id method. bzr revid: bth@tinyerp.com-20120309111644-7nzhptccx77dz996 --- addons/crm/crm_lead.py | 22 +++++++++++++--------- addons/crm/crm_lead_view.xml | 6 ++++++ addons/crm/crm_meeting.py | 19 +++++++++++++------ addons/crm/crm_meeting_view.xml | 3 +++ addons/crm/crm_phonecall.py | 13 ++++++++++--- addons/crm/crm_phonecall_view.xml | 3 +++ addons/mail/mail_thread_view.xml | 2 +- addons/sale_crm/wizard/crm_make_sale.py | 4 ++-- 8 files changed, 51 insertions(+), 21 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 46174c6ab67..b486c8d5f82 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -271,13 +271,21 @@ class crm_lead(crm_case, osv.osv): def stage_find_won(self, cr, uid, section_id): return self.stage_find_percent(cr, uid, 100.0, section_id) + def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None): + result = {} + 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 + return result + def _case_reset_notification(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): if lead.type == 'lead': message = _("Lead is renewed.") elif lead.type == 'opportunity': message = _("Opportunity is renewed.") - lead.message_append_note('' ,message, need_action_user_id=lead.user_id.id) + lead.message_append_note('' ,message) def _case_create_notification(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -289,7 +297,7 @@ class crm_lead(crm_case, osv.osv): else: message = _("Case is created.") self.message_append_note(cr, uid, ids, _('System notification'), - message, type='notification', need_action_user_id=obj.user_id.id, context=context) + message, type='notification', context=context) return True def _case_open_notification(self, lead, context=None): @@ -301,10 +309,9 @@ class crm_lead(crm_case, osv.osv): message = _("Opportunity is opened.") else: message = _("Case is opened.") - lead.message_append_note('' ,message, need_action_user_id=lead.user_id.id) + lead.message_append_note('' ,message) def _case_close_notification(self, lead, context=None): - lead[0].message_mark_done(context) if lead[0].type == 'lead': message = _("Lead is closed.") elif lead[0].type == 'opportunity': @@ -314,17 +321,14 @@ class crm_lead(crm_case, osv.osv): lead[0].message_append_note('' ,message) def _case_mark_lost_notification(self, lead, context=None): - lead.message_mark_done(context) message = _("Opportunity is marked as lost.") lead.message_append_note('' ,message) def _case_mark_won_notification(self, lead, context=None): - lead.message_mark_done(context) message = _("Opportunity is won.") lead.message_append_note('' ,message) def _case_cancel_notification(self, lead, context=None): - lead[0].message_mark_done(context) if lead[0].type == 'lead': message = _("Lead is cancelled.") elif lead[0].type == 'opportunity': @@ -514,7 +518,7 @@ class crm_lead(crm_case, osv.osv): subject = subject[0] + ", ".join(subject[1:]) details = "\n\n".join(details) - return opportunity.message_append_note(subject, body=details, need_action_user_id=opportunity.user_id.id) + return opportunity.message_append_note(subject, body=details) def _merge_opportunity_history(self, cr, uid, opportunity_id, opportunities, context=None): message = self.pool.get('mail.message') @@ -625,7 +629,7 @@ class crm_lead(crm_case, osv.osv): def _convert_opportunity_notification(self, cr, uid, lead, context=None): success_message = _("Lead is converted to an opportunity.") - lead.message_append_note(success_message ,success_message, need_action_user_id=lead.user_id.id) + lead.message_append_note(success_message ,success_message) return True def convert_opportunity(self, cr, uid, ids, partner_id, user_ids=False, section_id=False, context=None): diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index d27b24727a0..ca96617be25 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -168,6 +168,9 @@ + + + @@ -537,6 +540,9 @@ + + + diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 3bec7988ba5..580b0597593 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -85,6 +85,14 @@ class crm_meeting(crm_base, osv.osv): self._case_opportunity_meeting_notification(cr, uid, [obj_id], context=context) return obj_id + def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None): + result = {} + 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 + return result + def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None): lead_obj = self.pool.get('crm.lead') phonecall_obj = self.pool.get('crm.phonecall') @@ -94,32 +102,31 @@ class crm_meeting(crm_base, osv.osv): message = _("Meeting is scheduled on %s for opportunity.") % (obj.date) for lead in lead_obj.browse(cr, uid, [newid], context=context): lead.message_append_note('', message) - obj.message_append_note('', message, need_action_user_id=lead.user_id.id) + obj.message_append_note('', message) elif(obj.phonecall_id.id): newid = obj.phonecall_id.id message = _("Meeting is scheduled on %s for phonecall.") % (obj.date) for phonecall in phonecall_obj.browse(cr, uid, [newid], context=context): phonecall.message_append_note('', message) - obj.message_append_note('', message, need_action_user_id=phonecall.user_id.id) + obj.message_append_note('', message) else: message = _("Meeting is scheduled on %s .") % (obj.date) - obj.message_append_note('', message, need_action_user_id=obj.user_id.id) + obj.message_append_note('', message) def _case_close_notification(self, meeting, context=None): - meeting[0].message_mark_done(context) message = _("Meeting is done.") meeting[0].message_append_note('' ,message) def _case_reset_notification(self, cr, uid, ids, context=None): for meeting in self.browse(cr, uid, ids, context=context): message = _("Meeting is renewed.") - meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id) + meeting.message_append_note('' ,message) def _case_open_notification(self, meeting, context=None): if meeting.state != 'draft': return False message = _("Meeting is confirmed.") - meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id) + meeting.message_append_note('' ,message) def case_open(self, cr, uid, ids, context=None): """Confirms meeting diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index 353a2ea7f94..9a09caeb7d2 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -216,6 +216,9 @@ + + + diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index 74315786745..98deeea3ac3 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -90,8 +90,16 @@ class crm_phonecall(crm_base, osv.osv): 'user_id': lambda self,cr,uid,ctx: uid, 'active': 1, } + + def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None): + result = {} + 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 + return result + def _case_cancel_notification(self, phonecall, context=None): - phonecall[0].message_mark_done(context) message = _("Phonecall is cancelled.") phonecall[0].message_append_note( _('System notification'), message, type='notification', context=context) @@ -102,7 +110,6 @@ class crm_phonecall(crm_base, osv.osv): def done_notification(self, cr, uid, ids, context=None): for phonecall in self.browse(cr, uid, ids): - phonecall.message_mark_done(context) message = _("Phonecall is done.") self.message_append_note(cr, uid, [phonecall.id], _('System notification'), message, type='notification', context=context) @@ -110,7 +117,7 @@ class crm_phonecall(crm_base, osv.osv): def _case_open_notification(self, phonecall, context=None): phonecall.message_subscribe([phonecall.user_id.id], context=context) message = _("Phonecall is opened.") - phonecall.message_append_note('' ,message, need_action_user_id=phonecall.user_id.id) + phonecall.message_append_note('' ,message) # From crm.case def onchange_partner_address_id(self, cr, uid, ids, add, email=False): diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index d00c41bf73f..1e57d938593 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -123,6 +123,9 @@ states="cancel" type="object" icon="gtk-convert" /> + + + diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml index 4df16168499..48e60fe7f3c 100644 --- a/addons/mail/mail_thread_view.xml +++ b/addons/mail/mail_thread_view.xml @@ -27,7 +27,7 @@ - + diff --git a/addons/sale_crm/wizard/crm_make_sale.py b/addons/sale_crm/wizard/crm_make_sale.py index 1d898c5cc8d..832e3d2a7e0 100644 --- a/addons/sale_crm/wizard/crm_make_sale.py +++ b/addons/sale_crm/wizard/crm_make_sale.py @@ -106,8 +106,8 @@ class crm_make_sale(osv.osv_memory): sale_order = sale_obj.browse(cr, uid, new_id, context=context) case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id}) new_ids.append(new_id) - message = _("Opportunity %s is converted to Quotation %s.") % (case.name, sale_order.name) - case.message_append_note( _("Converted to Sales Quotation(%s).") % (sale_order.name),message,need_action_user_id=sale_order.user_id.id) + message = _("Opportunity is converted to Quotation %s.") % (sale_order.name) + case.message_append_note('', message) if make.close: case_obj.case_close(cr, uid, data) From edba2af7a27e7312b5db82e32aef709958779827 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Mon, 12 Mar 2012 16:04:20 +0530 Subject: [PATCH 09/13] [FIX] Improved language in notifications(present perfect simple with passive form) and imrpoved coding style. bzr revid: bth@tinyerp.com-20120312103420-hy4ln4pw0376173r --- addons/crm/crm.py | 31 +++---- addons/crm/crm_lead.py | 108 +++++++++++------------- addons/crm/crm_meeting.py | 33 +++++--- addons/crm/crm_phonecall.py | 46 ++++++---- addons/sale_crm/wizard/crm_make_sale.py | 2 +- 5 files changed, 112 insertions(+), 108 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 3aee3ec463a..61694b0d632 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -258,25 +258,22 @@ class crm_base(object): data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value']) return {'value': data} - def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None): + def _case_open_notification(self, cr, uid, ids, context=None): return True - def _case_open_notification(self, case, context=None): + def _case_close_notification(self, cr, uid, ids, context=None): return True - def _case_close_notification(self, case, context=None): + def _case_cancel_notification(self, cr, uid, ids, context=None): return True - def _case_cancel_notification(self, case, context=None): - return True - - def _case_pending_notification(self, case, context=None): + def _case_pending_notification(self, cr, uid, ids, context=None): return True def _case_reset_notification(self, cr, uid, ids, context=None): return True - def _case_escalate_notification(self, case, context=None): + def _case_escalate_notification(self, cr, uid, ids, context=None): return True def _case_phonecall_notification(self, case, action, context=None): @@ -292,7 +289,7 @@ class crm_base(object): if not case.user_id: data['user_id'] = uid self.write(cr, uid, [case.id], data) - self._case_open_notification(case, context=context) + self._case_open_notification(cr, uid, [case.id], context=context) self._action(cr, uid, cases, 'open') return True @@ -305,7 +302,7 @@ class crm_base(object): cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), }) # We use the cache of cases to keep the old case state - self._case_close_notification(cases, context=context) + self._case_close_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'done') return True @@ -317,7 +314,7 @@ class crm_base(object): cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'cancel', 'active': True}) # We use the cache of cases to keep the old case state - self._case_cancel_notification(cases, context=context) + self._case_cancel_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'cancel') return True @@ -328,7 +325,7 @@ class crm_base(object): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'pending', 'active': True}) - self._case_pending_notification(cases, context=context) + self._case_pending_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'pending') return True @@ -426,7 +423,7 @@ class crm_case(crm_base): if not case.user_id: data['user_id'] = uid self.write(cr, uid, [case.id], data) - self._case_open_notification(case, context=context) + self._case_open_notification(cr, uid, [case.id], context=context) self._action(cr, uid, cases, 'open') return True @@ -440,7 +437,7 @@ class crm_case(crm_base): # # We use the cache of cases to keep the old case state # - self._case_close_notification(cases, context=context) + self._case_close_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'done') return True @@ -458,7 +455,7 @@ class crm_case(crm_base): raise osv.except_osv(_('Error !'), _('You can not escalate, you are already at the top level regarding your sales-team category.')) self.write(cr, uid, [case.id], data) cases = self.browse(cr, uid, ids) - self._case_escalate_notification(cases, context=context) + self._case_escalate_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'escalate') return True @@ -468,7 +465,7 @@ class crm_case(crm_base): cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'cancel', 'active': True}) - self._case_cancel_notification(cases, context=context) + self._case_cancel_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'cancel') return True @@ -477,7 +474,7 @@ class crm_case(crm_base): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'pending', 'active': True}) - self._case_pending_notification(cases, context=context) + self._case_pending_notification(cr, uid, ids, context=context) self._action(cr, uid, cases, 'pending') return True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b486c8d5f82..3e99baaa095 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -281,70 +281,61 @@ class crm_lead(crm_case, osv.osv): def _case_reset_notification(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): - if lead.type == 'lead': - message = _("Lead is renewed.") - elif lead.type == 'opportunity': - message = _("Opportunity is renewed.") + message = _("%s has been renewed.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') lead.message_append_note('' ,message) + return True def _case_create_notification(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) - if obj.type=="opportunity" and obj.state=="draft": - message = _("Opportunity is created.") - elif obj.type=="lead" : - message = _("Lead is created.") - else: - message = _("Case is created.") + for lead in self.browse(cr, uid, ids, context=context): + self.message_subscribe(cr, uid, ids, [lead.user_id.id], context=context) + message = _("%s has been created.") % ('Opportunity' if lead.type == 'opportunity' and lead.state == 'draft' else 'Lead') self.message_append_note(cr, uid, ids, _('System notification'), message, type='notification', context=context) return True - def _case_open_notification(self, lead, context=None): - if lead.state != 'draft' and lead.state != 'pending': - return False - if lead.type == 'lead': - message = _("Lead is opened.") - elif lead.type == 'opportunity': - message = _("Opportunity is opened.") - else: - message = _("Case is opened.") - lead.message_append_note('' ,message) + def _case_open_notification(self, cr, uid, ids, context=None): + for lead in self.browse(cr, uid, ids, context=context): + if lead.state == 'draft' and lead.state == 'pending': + return False + message = _("%s has been opened.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') + lead.message_append_note('' ,message) + return True - def _case_close_notification(self, lead, context=None): - if lead[0].type == 'lead': - message = _("Lead is closed.") - elif lead[0].type == 'opportunity': - message = _("Opportunity is closed.") - else: - message = _("Case is closed.") - lead[0].message_append_note('' ,message) + def _case_close_notification(self, cr, uid, ids, context=None): + for lead in self.browse(cr, uid, ids, context=context): + message = _("%s has been closed.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') + lead.message_append_note('' ,message) + return True - def _case_mark_lost_notification(self, lead, context=None): - message = _("Opportunity is marked as lost.") - lead.message_append_note('' ,message) + def _case_mark_lost_notification(self, cr, uid, ids, context=None): + for opportunity in self.browse(cr, uid, ids, context=context): + message = _("Opportunity has been marked as lost.") + opportunity.message_append_note('' ,message) + return True - def _case_mark_won_notification(self, lead, context=None): - message = _("Opportunity is won.") - lead.message_append_note('' ,message) + def _case_mark_won_notification(self, cr, uid, ids, context=None): + for opportunity in self.browse(cr, uid, ids, context=context): + message = _("Opportunity has been won.") + opportunity.message_append_note('' ,message) + return True - def _case_cancel_notification(self, lead, context=None): - if lead[0].type == 'lead': - message = _("Lead is cancelled.") - elif lead[0].type == 'opportunity': - message = _("Opportunity is cancelled.") - lead[0].message_append_note('' ,message) + def _case_cancel_notification(self, cr, uid, ids, context=None): + for lead in self.browse(cr, uid, ids, context=context): + message = _("%s has been cancelled.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') + lead.message_append_note('' ,message) + return True - def _case_pending_notification(self, case, context=None): - if case[0].type == 'lead': - message = _("Lead is pending.") - elif case[0].type == 'opportunity': - message = _("Opportunity is pending.") - case[0].message_append_note('' ,message) + def _case_pending_notification(self, cr, uid, ids, context=None): + for lead in self.browse(cr, uid, ids, context=context): + message = _("%s is pending.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') + lead.message_append_note('' ,message) + return True - def _case_escalate_notification(self, case, context=None): - message = _("Lead is escalated.") - case.message_append_note('' ,message) + def _case_escalate_notification(self, cr, uid, ids, context=None): + for lead in self.browse(cr, uid, ids, context=context): + message = _("Lead has been escalated.") + lead.message_append_note('' ,message) + return True def _case_phonecall_notification(self, cr, uid, ids, case, phonecall, action, context=None): for obj in phonecall.browse(cr, uid, ids, context=context): @@ -354,12 +345,11 @@ class crm_lead(crm_case, osv.osv): message = _("%s a call.") % (action) case.message_append_note('', message) - def _case_partner_notification(self, lead, context=None): - if lead.type == 'lead': - message = _("Partner is created for this lead.") - elif lead.type == 'opportunity': - message = _("Partner is created for this opportunity.") - lead.message_append_note('' ,message) + def _case_partner_notification(self, cr, uid, ids, context=None): + for lead in self.browse(cr, uid, ids, context=context): + message = _("Partner is created for this %s") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') + lead.message_append_note('' ,message) + return True def case_open(self, cr, uid, ids, context=None): res = super(crm_lead, self).case_open(cr, uid, ids, context) @@ -412,7 +402,7 @@ class crm_lead(crm_case, osv.osv): stage_id = self.stage_find_won(cr, uid, lead.section_id.id or False) if stage_id: self.stage_set(cr, uid, [lead.id], stage_id) - self._case_mark_won_notification(lead, context=context) + self._case_mark_won_notification(cr, uid, [lead.id], context=context) return res def set_priority(self, cr, uid, ids, priority): @@ -674,7 +664,7 @@ class crm_lead(crm_case, osv.osv): res_partner.write(cr, uid, partner_id, {'section_id': lead.section_id.id or False}) contact_id = res_partner.address_get(cr, uid, [partner_id])['default'] res = lead.write({'partner_id' : partner_id, 'partner_address_id': contact_id}, context=context) - self._case_partner_notification(lead,context) + self._case_partner_notification(cr, uid, [lead.id], context) return res def _lead_create_partner_address(self, cr, uid, lead, partner_id, context=None): diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 580b0597593..9bc5f44d1ce 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -99,34 +99,39 @@ class crm_meeting(crm_base, osv.osv): for obj in self.browse(cr, uid, ids, context=context): if(obj.opportunity_id.id): newid = obj.opportunity_id.id - message = _("Meeting is scheduled on %s for opportunity.") % (obj.date) + message = _("Meeting has been scheduled on %s for opportunity.") % (obj.date) for lead in lead_obj.browse(cr, uid, [newid], context=context): lead.message_append_note('', message) obj.message_append_note('', message) elif(obj.phonecall_id.id): newid = obj.phonecall_id.id - message = _("Meeting is scheduled on %s for phonecall.") % (obj.date) + message = _("Meeting has been scheduled on %s for phonecall.") % (obj.date) for phonecall in phonecall_obj.browse(cr, uid, [newid], context=context): phonecall.message_append_note('', message) obj.message_append_note('', message) else: - message = _("Meeting is scheduled on %s .") % (obj.date) + message = _("Meeting has been scheduled on %s .") % (obj.date) obj.message_append_note('', message) - def _case_close_notification(self, meeting, context=None): - message = _("Meeting is done.") - meeting[0].message_append_note('' ,message) - - def _case_reset_notification(self, cr, uid, ids, context=None): + def _case_close_notification(self, cr, uid, ids, context=None): for meeting in self.browse(cr, uid, ids, context=context): - message = _("Meeting is renewed.") + message = _("Meeting has been done.") meeting.message_append_note('' ,message) + return True - def _case_open_notification(self, meeting, context=None): - if meeting.state != 'draft': - return False - message = _("Meeting is confirmed.") - meeting.message_append_note('' ,message) + def _case_reset_notification(self, cr, uid, ids, context=None): + for meeting in self.browse(cr, uid, ids, context=context): + message = _("Meeting has been renewed.") + meeting.message_append_note('' ,message) + return True + + def _case_open_notification(self, cr, uid, ids, context=None): + for meeting in self.browse(cr, uid, ids, context=context): + if meeting.state != 'draft': + return False + message = _("Meeting has been confirmed.") + meeting.message_append_note('' ,message) + return True def case_open(self, cr, uid, ids, context=None): """Confirms meeting diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index 98deeea3ac3..9fa007bcf9a 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -99,25 +99,37 @@ class crm_phonecall(crm_base, osv.osv): result[obj.id] = obj.user_id.id return result - def _case_cancel_notification(self, phonecall, context=None): - message = _("Phonecall is cancelled.") - phonecall[0].message_append_note( _('System notification'), + def _case_cancel_notification(self, cr, uid, ids, context=None): + for phonecall in self.browse(cr, uid, ids, context=context): + message = _("Phonecall has been cancelled.") + phonecall.message_append_note( _('System notification'), message, type='notification', context=context) + return True - def _case_pending_notification(self, phonecall, context=None): - message = _("Phonecall is pending.") - phonecall[0].message_append_note('' ,message) + def _case_pending_notification(self, cr, uid, ids, context=None): + for phonecall in self.browse(cr, uid, ids, context=context): + message = _("Phonecall is pending.") + phonecall.message_append_note('' ,message) + return True def done_notification(self, cr, uid, ids, context=None): - for phonecall in self.browse(cr, uid, ids): - message = _("Phonecall is done.") - self.message_append_note(cr, uid, [phonecall.id], _('System notification'), - message, type='notification', context=context) + for phonecall in self.browse(cr, uid, ids, context=context): + message = _("Phonecall has been done.") + phonecall.message_append_note('', message) + return True - def _case_open_notification(self, phonecall, context=None): - phonecall.message_subscribe([phonecall.user_id.id], context=context) - message = _("Phonecall is opened.") - phonecall.message_append_note('' ,message) + def _case_open_notification(self, cr, uid, ids, context=None): + for phonecall in self.browse(cr, uid, ids, context=context): + phonecall.message_subscribe([phonecall.user_id.id], context=context) + message = _("Phonecall has been opened.") + phonecall.message_append_note('' ,message) + return True + + def _case_partner_notification(self, cr, uid, ids, context=None): + for phonecall in self.browse(cr, uid, ids, context=context): + message = _("Partner is created") + phonecall.message_append_note('' ,message) + return True # From crm.case def onchange_partner_address_id(self, cr, uid, ids, add, email=False): @@ -149,8 +161,7 @@ class crm_phonecall(crm_base, osv.osv): """ res = super(crm_phonecall, self).case_reset(cr, uid, ids, context) self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'}) - for phone in self.browse(cr, uid, ids): - self._case_open_notification(phone, context=context) + self._case_open_notification(cr, uid, ids, context=context) return res @@ -208,7 +219,8 @@ class crm_phonecall(crm_base, osv.osv): return partner_id def _call_set_partner(self, cr, uid, ids, partner_id, context=None): - return self.write(cr, uid, ids, {'partner_id' : partner_id}, context=context) + self.write(cr, uid, ids, {'partner_id' : partner_id}, context=context) + self._case_partner_notification(cr, uid, ids, context) def _call_create_partner_address(self, cr, uid, phonecall, partner_id, context=None): address = self.pool.get('res.partner.address') diff --git a/addons/sale_crm/wizard/crm_make_sale.py b/addons/sale_crm/wizard/crm_make_sale.py index 832e3d2a7e0..358bf117d56 100644 --- a/addons/sale_crm/wizard/crm_make_sale.py +++ b/addons/sale_crm/wizard/crm_make_sale.py @@ -106,7 +106,7 @@ class crm_make_sale(osv.osv_memory): sale_order = sale_obj.browse(cr, uid, new_id, context=context) case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id}) new_ids.append(new_id) - message = _("Opportunity is converted to Quotation %s.") % (sale_order.name) + message = _("Opportunity has been converted to Quotation %s.") % (sale_order.name) case.message_append_note('', message) if make.close: From 746a4e202ffc5082b0589b3a8dfc267d5984b747 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Mon, 12 Mar 2012 16:45:38 +0530 Subject: [PATCH 10/13] [FIX] Improved language in notification for partner creation. bzr revid: bth@tinyerp.com-20120312111538-2rkydsbl39f040gq --- addons/crm/crm_lead.py | 2 +- addons/crm/crm_phonecall.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 3e99baaa095..302b61e4274 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -347,7 +347,7 @@ class crm_lead(crm_case, osv.osv): def _case_partner_notification(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): - message = _("Partner is created for this %s") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') + message = _("Partner has created for this %s") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') lead.message_append_note('' ,message) return True diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index 9fa007bcf9a..7514a168dbd 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -127,7 +127,7 @@ class crm_phonecall(crm_base, osv.osv): def _case_partner_notification(self, cr, uid, ids, context=None): for phonecall in self.browse(cr, uid, ids, context=context): - message = _("Partner is created") + message = _("Partner has been created") phonecall.message_append_note('' ,message) return True From be5a0f4aa3fc456f5c2732d84c00c21e429583a5 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Mon, 12 Mar 2012 18:45:25 +0530 Subject: [PATCH 11/13] [FIX] rename method name for meeting creation notification and escalate notification method is replaced from crm_base to crm_case. bzr revid: bth@tinyerp.com-20120312131525-0rr3sr1peh30r8ee --- addons/crm/crm.py | 6 +++--- addons/crm/crm_meeting.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 61694b0d632..d7edfaa7fa9 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -273,9 +273,6 @@ class crm_base(object): def _case_reset_notification(self, cr, uid, ids, context=None): return True - def _case_escalate_notification(self, cr, uid, ids, context=None): - return True - def _case_phonecall_notification(self, case, action, context=None): return True @@ -415,6 +412,9 @@ class crm_case(crm_base): default.update({ 'date_open': False }) return super(crm_case, self).copy(cr, uid, id, default, context=context) + def _case_escalate_notification(self, cr, uid, ids, context=None): + return True + def case_open(self, cr, uid, ids, context=None): """Opens Case""" cases = self.browse(cr, uid, ids) diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index 9bc5f44d1ce..033eb0da699 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -82,7 +82,7 @@ class crm_meeting(crm_base, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_meeting, self).create(cr, uid, vals, context=context) - self._case_opportunity_meeting_notification(cr, uid, [obj_id], context=context) + self._case_create_notification(cr, uid, [obj_id], context=context) return obj_id def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None): @@ -93,11 +93,11 @@ class crm_meeting(crm_base, osv.osv): result[obj.id] = obj.user_id.id return result - def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None): + def _case_create_notification(self, cr, uid, ids, context=None): lead_obj = self.pool.get('crm.lead') phonecall_obj = self.pool.get('crm.phonecall') for obj in self.browse(cr, uid, ids, context=context): - if(obj.opportunity_id.id): + if(obj.opportunity_id.id): # meeting can be create from phonecalls or opportunities, therefore checking for the parent newid = obj.opportunity_id.id message = _("Meeting has been scheduled on %s for opportunity.") % (obj.date) for lead in lead_obj.browse(cr, uid, [newid], context=context): From ed07444999e9e83844098d610e5d3615e8568400 Mon Sep 17 00:00:00 2001 From: "Bhumi Thakkar (Open ERP)" Date: Tue, 13 Mar 2012 16:25:28 +0530 Subject: [PATCH 12/13] [FIX] renamed methods' name and notifications changed for meeting and phonecall and remove need_action_user_id field from view and language improved in notification message. bzr revid: bth@tinyerp.com-20120313105528-6e1ag1w5a5sbzsnj --- addons/crm/crm.py | 35 +++++++++---------- addons/crm/crm_lead.py | 56 +++++++++++++------------------ addons/crm/crm_lead_view.xml | 19 ++++------- addons/crm/crm_meeting.py | 19 ++++++----- addons/crm/crm_meeting_view.xml | 3 -- addons/crm/crm_phonecall.py | 31 +++++++++++------ addons/crm/crm_phonecall_view.xml | 3 -- 7 files changed, 78 insertions(+), 88 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index d7edfaa7fa9..7f0fb344492 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -258,22 +258,19 @@ class crm_base(object): data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value']) return {'value': data} - def _case_open_notification(self, cr, uid, ids, context=None): + def case_open_send_note(self, cr, uid, ids, context=None): return True - def _case_close_notification(self, cr, uid, ids, context=None): + def case_close_send_note(self, cr, uid, ids, context=None): return True - def _case_cancel_notification(self, cr, uid, ids, context=None): + def case_cancel_send_note(self, cr, uid, ids, context=None): return True - def _case_pending_notification(self, cr, uid, ids, context=None): + def case_pending_send_note(self, cr, uid, ids, context=None): return True - def _case_reset_notification(self, cr, uid, ids, context=None): - return True - - def _case_phonecall_notification(self, case, action, context=None): + def case_reset_send_note(self, cr, uid, ids, context=None): return True def case_open(self, cr, uid, ids, context=None): @@ -286,7 +283,7 @@ class crm_base(object): if not case.user_id: data['user_id'] = uid self.write(cr, uid, [case.id], data) - self._case_open_notification(cr, uid, [case.id], context=context) + self.case_open_send_note(cr, uid, [case.id], context=context) self._action(cr, uid, cases, 'open') return True @@ -299,7 +296,7 @@ class crm_base(object): cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), }) # We use the cache of cases to keep the old case state - self._case_close_notification(cr, uid, ids, context=context) + self.case_close_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'done') return True @@ -311,7 +308,7 @@ class crm_base(object): cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'cancel', 'active': True}) # We use the cache of cases to keep the old case state - self._case_cancel_notification(cr, uid, ids, context=context) + self.case_cancel_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'cancel') return True @@ -322,7 +319,7 @@ class crm_base(object): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'pending', 'active': True}) - self._case_pending_notification(cr, uid, ids, context=context) + self.case_pending_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'pending') return True @@ -333,7 +330,7 @@ class crm_base(object): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'draft', 'active': True}) - self._case_reset_notification(cr, uid, ids, context=context) + self.case_reset_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'draft') return True @@ -412,7 +409,7 @@ class crm_case(crm_base): default.update({ 'date_open': False }) return super(crm_case, self).copy(cr, uid, id, default, context=context) - def _case_escalate_notification(self, cr, uid, ids, context=None): + def case_escalate_send_note(self, cr, uid, ids, context=None): return True def case_open(self, cr, uid, ids, context=None): @@ -423,7 +420,7 @@ class crm_case(crm_base): if not case.user_id: data['user_id'] = uid self.write(cr, uid, [case.id], data) - self._case_open_notification(cr, uid, [case.id], context=context) + self.case_open_send_note(cr, uid, [case.id], context=context) self._action(cr, uid, cases, 'open') return True @@ -437,7 +434,7 @@ class crm_case(crm_base): # # We use the cache of cases to keep the old case state # - self._case_close_notification(cr, uid, ids, context=context) + self.case_close_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'done') return True @@ -455,7 +452,7 @@ class crm_case(crm_base): raise osv.except_osv(_('Error !'), _('You can not escalate, you are already at the top level regarding your sales-team category.')) self.write(cr, uid, [case.id], data) cases = self.browse(cr, uid, ids) - self._case_escalate_notification(cr, uid, ids, context=context) + self.case_escalate_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'escalate') return True @@ -465,7 +462,7 @@ class crm_case(crm_base): cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'cancel', 'active': True}) - self._case_cancel_notification(cr, uid, ids, context=context) + self.case_cancel_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'cancel') return True @@ -474,7 +471,7 @@ class crm_case(crm_base): cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.write(cr, uid, ids, {'state': 'pending', 'active': True}) - self._case_pending_notification(cr, uid, ids, context=context) + self.case_pending_send_note(cr, uid, ids, context=context) self._action(cr, uid, cases, 'pending') return True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 302b61e4274..a8ec106e6de 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -226,7 +226,7 @@ class crm_lead(crm_case, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) - self._case_create_notification(cr, uid, [obj_id], context=context) + self.case_create_send_note(cr, uid, [obj_id], context=context) return obj_id @@ -279,13 +279,13 @@ class crm_lead(crm_case, osv.osv): result[obj.id] = obj.user_id.id return result - def _case_reset_notification(self, cr, uid, ids, context=None): + def case_reset_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s has been renewed.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') lead.message_append_note('' ,message) return True - def _case_create_notification(self, cr, uid, ids, context=None): + def case_create_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): self.message_subscribe(cr, uid, ids, [lead.user_id.id], context=context) message = _("%s has been created.") % ('Opportunity' if lead.type == 'opportunity' and lead.state == 'draft' else 'Lead') @@ -293,7 +293,7 @@ class crm_lead(crm_case, osv.osv): message, type='notification', context=context) return True - def _case_open_notification(self, cr, uid, ids, context=None): + def case_open_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): if lead.state == 'draft' and lead.state == 'pending': return False @@ -301,53 +301,50 @@ class crm_lead(crm_case, osv.osv): lead.message_append_note('' ,message) return True - def _case_close_notification(self, cr, uid, ids, context=None): + def case_close_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s has been closed.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') lead.message_append_note('' ,message) return True - def _case_mark_lost_notification(self, cr, uid, ids, context=None): + def case_mark_lost_send_note(self, cr, uid, ids, context=None): for opportunity in self.browse(cr, uid, ids, context=context): message = _("Opportunity has been marked as lost.") opportunity.message_append_note('' ,message) return True - def _case_mark_won_notification(self, cr, uid, ids, context=None): + def case_mark_won_send_note(self, cr, uid, ids, context=None): for opportunity in self.browse(cr, uid, ids, context=context): message = _("Opportunity has been won.") opportunity.message_append_note('' ,message) return True - def _case_cancel_notification(self, cr, uid, ids, context=None): + def case_cancel_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s has been cancelled.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') lead.message_append_note('' ,message) return True - def _case_pending_notification(self, cr, uid, ids, context=None): + def case_pending_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s is pending.") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') lead.message_append_note('' ,message) return True - def _case_escalate_notification(self, cr, uid, ids, context=None): + def case_escalate_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("Lead has been escalated.") lead.message_append_note('' ,message) return True - def _case_phonecall_notification(self, cr, uid, ids, case, phonecall, action, context=None): + def case_phonecall_send_note(self, cr, uid, ids, case, phonecall, action, context=None): for obj in phonecall.browse(cr, uid, ids, context=context): - if action == "schedule" : - message = _("%s a call for the %s.") % (action, obj.date) - else : - message = _("%s a call.") % (action) + message = _("%s a call for the %s.") % (action, obj.date) case.message_append_note('', message) - def _case_partner_notification(self, cr, uid, ids, context=None): + def case_partner_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): - message = _("Partner has created for this %s") % ('Opportunity' if lead.type == 'opportunity' else 'Lead') + message = _("Partner has been created") lead.message_append_note('' ,message) return True @@ -379,7 +376,7 @@ class crm_lead(crm_case, osv.osv): """ res = super(crm_lead, self).case_reset(cr, uid, ids, context) self.write(cr, uid, ids, {'stage_id': False, 'probability': 0.0}) - self._case_reset_notification(cr, uid, ids, context=context) + self.case_reset_send_note(cr, uid, ids, context=context) return res def case_mark_lost(self, cr, uid, ids, context=None): @@ -402,7 +399,7 @@ class crm_lead(crm_case, osv.osv): stage_id = self.stage_find_won(cr, uid, lead.section_id.id or False) if stage_id: self.stage_set(cr, uid, [lead.id], stage_id) - self._case_mark_won_notification(cr, uid, [lead.id], context=context) + self.case_mark_won_send_note(cr, uid, [lead.id], context=context) return res def set_priority(self, cr, uid, ids, priority): @@ -617,9 +614,9 @@ class crm_lead(crm_case, osv.osv): 'partner_address_id': contact_id, } - def _convert_opportunity_notification(self, cr, uid, lead, context=None): - success_message = _("Lead is converted to an opportunity.") - lead.message_append_note(success_message ,success_message) + def convert_opportunity_send_note(self, cr, uid, lead, context=None): + message = _("Lead has been converted to an opportunity.") + lead.message_append_note('' ,message) return True def convert_opportunity(self, cr, uid, ids, partner_id, user_ids=False, section_id=False, context=None): @@ -637,7 +634,7 @@ class crm_lead(crm_case, osv.osv): vals = self._convert_opportunity_data(cr, uid, lead, customer, section_id, context=context) self.write(cr, uid, [lead.id], vals, context=context) - self._convert_opportunity_notification(cr, uid, lead, context=context) + self.convert_opportunity_send_note(cr, uid, lead, context=context) #TOCHECK: why need to change partner details in all messages of lead ? if lead.partner_id: msg_ids = [ x.id for x in lead.message_ids] @@ -664,7 +661,7 @@ class crm_lead(crm_case, osv.osv): res_partner.write(cr, uid, partner_id, {'section_id': lead.section_id.id or False}) contact_id = res_partner.address_get(cr, uid, [partner_id])['default'] res = lead.write({'partner_id' : partner_id, 'partner_address_id': contact_id}, context=context) - self._case_partner_notification(cr, uid, [lead.id], context) + self.case_partner_send_note(cr, uid, [lead.id], context) return res def _lead_create_partner_address(self, cr, uid, lead, partner_id, context=None): @@ -770,7 +767,7 @@ class crm_lead(crm_case, osv.osv): if action == 'log': phonecall.case_close(cr, uid, [new_id]) phonecall_dict[lead.id] = new_id - self._case_phonecall_notification(cr, uid, [new_id], lead, phonecall, action, context=context) + self.case_phonecall_send_note(cr, uid, [new_id], lead, phonecall, action, context=context) return phonecall_dict @@ -913,13 +910,8 @@ class crm_lead(crm_case, osv.osv): if not vals.get('probability') and stage.on_change: vals['probability'] = stage.probability for case in self.browse(cr, uid, ids, context=context): - if case.type == 'lead' or context.get('stage_type') == 'lead': - message = _("Changed to %s.") % (stage.name) - case.message_append_note('', message) - elif case.type == 'opportunity': - message = _("Changed to %s.") % (stage.name) - case.message_append_note('', message) - + message = _("Stage changed to %s.") % (stage.name) + case.message_append_note('', message) return super(crm_lead,self).write(cr, uid, ids, vals, context) crm_lead() diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index ca96617be25..98e1ee2f6b5 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -77,9 +77,10 @@ icon="gtk-go-forward" context="{'stage_type': 'lead'}" /> +