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: