From 13b59bec4c2bff9910c759967784261ca1f3aa8e Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 23 Feb 2011 11:37:37 +0530 Subject: [PATCH 1/5] [FIX]: crm - send reminder uses wrong "from" email bzr revid: atp@tinyerp.com-20110223060737-88tydzckko1b4j8m --- addons/base_action_rule/base_action_rule.py | 1 + addons/crm/crm.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 2a4e2c0e4e1..e22b6869c91 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -398,6 +398,7 @@ the rule to mark CC(mail to any other person defined in actions)."), if hasattr(model_obj, 'remind_user') and action.act_remind_user: model_obj.remind_user(cr, uid, [obj.id], context, attach=action.act_remind_attach) if hasattr(model_obj, 'remind_partner') and action.act_remind_partner: + context.update({'remind_partner': True}) model_obj.remind_partner(cr, uid, [obj.id], context, attach=action.act_remind_attach) if action.act_method: getattr(model_obj, 'act_method')(cr, uid, [obj.id], action, context) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index f4e31575544..da216b31274 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -441,6 +441,7 @@ class crm_case(object): @param context: A standard dictionary for contextual values """ + return self.remind_user(cr, uid, ids, context, attach, destination=False) @@ -451,15 +452,19 @@ class crm_case(object): @param uid: the current user’s ID for security checks, @param ids: List of Remind user's IDs @param context: A standard dictionary for contextual values - """ for case in self.browse(cr, uid, ids, context=context): if not case.section_id.reply_to: raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team")) - if not case.email_from: + + if context.get('remind_partner') and not case.email_from: raise osv.except_osv(_('Error!'), ("Partner Email is not specified in Case")) - if case.section_id.reply_to and case.email_from: - src = case.email_from + elif not context.get('remind_partner') and not case.user_id.user_email: + raise osv.except_osv(_('Error!'), ("User Email is not specified in Case")) + + case_email = context.get('remind_partner') and case.email_from or case.user_id.user_email + if case.section_id.reply_to and case_email: + src = case_email dest = case.section_id.reply_to body = case.description or "" if case.message_ids: From f6306b53ea3ccb4ed5a37cf5c15389604a76b97a Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 2 Mar 2011 15:58:38 +0530 Subject: [PATCH 2/5] [FIX]crm: set salesteam responsible user as remind user for send remind user action. bzr revid: atp@tinyerp.com-20110302102838-hwg2fqahjpxkoxnz --- addons/base_action_rule/base_action_rule.py | 1 - addons/crm/crm.py | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index e22b6869c91..2a4e2c0e4e1 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -398,7 +398,6 @@ the rule to mark CC(mail to any other person defined in actions)."), if hasattr(model_obj, 'remind_user') and action.act_remind_user: model_obj.remind_user(cr, uid, [obj.id], context, attach=action.act_remind_attach) if hasattr(model_obj, 'remind_partner') and action.act_remind_partner: - context.update({'remind_partner': True}) model_obj.remind_partner(cr, uid, [obj.id], context, attach=action.act_remind_attach) if action.act_method: getattr(model_obj, 'act_method')(cr, uid, [obj.id], action, context) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index da216b31274..e566d119bf6 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -456,13 +456,15 @@ class crm_case(object): for case in self.browse(cr, uid, ids, context=context): if not case.section_id.reply_to: raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team")) - - if context.get('remind_partner') and not case.email_from: + if not case.email_from: raise osv.except_osv(_('Error!'), ("Partner Email is not specified in Case")) - elif not context.get('remind_partner') and not case.user_id.user_email: - raise osv.except_osv(_('Error!'), ("User Email is not specified in Case")) - - case_email = context.get('remind_partner') and case.email_from or case.user_id.user_email + if not case.user_id.user_email: + raise osv.except_osv(_('Error!'), ("User Email is not specified in Case")) + if case.section_id.user_id: + case_email = case.section_id.user_id.user_email + else: + case_email = case.user_id.user_email + if case.section_id.reply_to and case_email: src = case_email dest = case.section_id.reply_to @@ -470,6 +472,7 @@ class crm_case(object): if case.message_ids: body = case.message_ids[0].description or "" if not destination: + src = case.email_from src, dest = dest, src if body and case.user_id.signature: if body: From edd32485de1cd0308f29528d2f6c806e5b3b5275 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Wed, 2 Mar 2011 13:29:07 +0100 Subject: [PATCH 3/5] [FIX] raise an exception on case.email only if need to remind partner bzr revid: tfr@openerp.com-20110302122907-ex23dr1jzuuyjghs --- addons/crm/crm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index e566d119bf6..4be129762cb 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -441,7 +441,7 @@ class crm_case(object): @param context: A standard dictionary for contextual values """ - + return self.remind_user(cr, uid, ids, context, attach, destination=False) @@ -456,15 +456,15 @@ class crm_case(object): for case in self.browse(cr, uid, ids, context=context): if not case.section_id.reply_to: raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team")) - if not case.email_from: + if not destination and not case.email_from: raise osv.except_osv(_('Error!'), ("Partner Email is not specified in Case")) if not case.user_id.user_email: raise osv.except_osv(_('Error!'), ("User Email is not specified in Case")) if case.section_id.user_id: - case_email = case.section_id.user_id.user_email + case_email = case.section_id.user_id.user_email else: - case_email = case.user_id.user_email - + case_email = case.user_id.user_email + if case.section_id.reply_to and case_email: src = case_email dest = case.section_id.reply_to From 2b7ba42ea988ad61bb0ae8e460473dc6cef99ee1 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Fri, 4 Mar 2011 11:27:50 +0100 Subject: [PATCH 4/5] [FIX] opt-in, opt-out in opportunities and typo bzr revid: tfr@openerp.com-20110304102750-ujj2tmml1lur3zef --- addons/crm/crm_lead.py | 12 ++++-------- addons/crm/crm_lead_view.xml | 4 ++-- addons/crm/crm_opportunity_view.xml | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index aa424bb3e8c..921c1c83651 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -413,15 +413,11 @@ class crm_lead(crm_case, osv.osv): """ return True - def on_chnage_optin(self, cr, uid, ids, optin): - if optin: - return {'value':{'optin':optin,'optout':False}} - return {} + def on_change_optin(self, cr, uid, ids, optin): + return {'value':{'optin':optin,'optout':False}} - def on_chnage_optout(self, cr, uid, ids, optout): - if optout: - return {'value':{'optout':optout,'optin':False}} - return {} + def on_change_optout(self, cr, uid, ids, optout): + return {'value':{'optout':optout,'optin':False}} crm_lead() diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 2546ee0ca0f..0f75e4dbb02 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -151,8 +151,8 @@ - - + + diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml index ee41e865b2d..27f0edad17d 100644 --- a/addons/crm/crm_opportunity_view.xml +++ b/addons/crm/crm_opportunity_view.xml @@ -141,8 +141,8 @@ - - + + From 4cead9e021f3d66d4f30d647fa17721a146a3508 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Fri, 4 Mar 2011 13:13:36 +0100 Subject: [PATCH 5/5] [FIX] exception raise when not reply to remove, email send to user not to reply_to of the sales team bzr revid: tfr@openerp.com-20110304121336-lcj3586ayaalq19v --- addons/crm/crm.py | 68 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 4be129762cb..9b266314a86 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -450,57 +450,55 @@ class crm_case(object): @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param ids: List of Remind user's IDs + @param ids: List of case's IDs to remind @param context: A standard dictionary for contextual values """ for case in self.browse(cr, uid, ids, context=context): - if not case.section_id.reply_to: - raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team")) if not destination and not case.email_from: raise osv.except_osv(_('Error!'), ("Partner Email is not specified in Case")) if not case.user_id.user_email: raise osv.except_osv(_('Error!'), ("User Email is not specified in Case")) - if case.section_id.user_id: + + if destination and case.section_id.user_id: case_email = case.section_id.user_id.user_email else: case_email = case.user_id.user_email - if case.section_id.reply_to and case_email: - src = case_email - dest = case.section_id.reply_to - body = case.description or "" - if case.message_ids: - body = case.message_ids[0].description or "" - if not destination: - src = case.email_from - src, dest = dest, src - if body and case.user_id.signature: - if body: - body += '\n\n%s' % (case.user_id.signature) - else: - body = '\n\n%s' % (case.user_id.signature) + src = case_email + dest = case.user_id + body = case.description or "" + if case.message_ids: + body = case.message_ids[0].description or "" + if not destination: + src, dest = dest, case.email_from + if body and case.user_id.signature: + if body: + body += '\n\n%s' % (case.user_id.signature) + else: + body = '\n\n%s' % (case.user_id.signature) - body = self.format_body(body) + body = self.format_body(body) - attach_to_send = None + attach_to_send = None - if attach: - attach_ids = self.pool.get('ir.attachment').search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', case.id)]) - attach_to_send = self.pool.get('ir.attachment').read(cr, uid, attach_ids, ['datas_fname','datas']) - attach_to_send = map(lambda x: (x['datas_fname'], base64.decodestring(x['datas'])), attach_to_send) + if attach: + attach_ids = self.pool.get('ir.attachment').search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', case.id)]) + attach_to_send = self.pool.get('ir.attachment').read(cr, uid, attach_ids, ['datas_fname', 'datas']) + attach_to_send = map(lambda x: (x['datas_fname'], base64.decodestring(x['datas'])), attach_to_send) # Send an email - subject = "Reminder: [%s] %s" % (str(case.id), case.name, ) - tools.email_send( - src, - [dest], - subject, - body, - reply_to=case.section_id.reply_to, - openobject_id=str(case.id), - attach=attach_to_send - ) - self._history(cr, uid, [case], _('Send'), history=True, subject=subject, email=dest, details=body, email_from=src) + subject = "Reminder: [%s] %s" % (str(case.id), case.name,) + tools.email_send( + src, + [dest], + subject, + body, + reply_to=case.section_id.reply_to or '', + openobject_id=str(case.id), + attach=attach_to_send + ) + self._history(cr, uid, [case], _('Send'), history=True, subject=subject, email=dest, details=body, email_from=src) + return True def _check(self, cr, uid, ids=False, context=None):