diff --git a/addons/crm/crm.py b/addons/crm/crm.py index ea3d330c1e5..80e1b8e246a 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -370,9 +370,9 @@ class crm_case(osv.osv): if history: obj = self.pool.get('crm.case.history') data['description'] = details or case.description - data['email'] = email or \ - (case.user_id and case.user_id.address_id and \ - case.user_id.address_id.email) or False + data['email'] = email or False + data['email_from'] = (case.user_id and case.user_id.address_id and \ + case.user_id.address_id.email) or tools.config.get('email_from',False) res = obj.create(cr, uid, data, context) return True _history = __history @@ -559,6 +559,7 @@ class crm_case_history(osv.osv): 'description': fields.text('Description'), 'note': fields.function(_note_get, method=True, string="Description", type="text"), 'email': fields.char('Email', size=84), + 'email_from' : fields.char('From Email', size=84), 'log_id': fields.many2one('crm.case.log', 'Log', ondelete='cascade'), } crm_case_history() diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py index 17442fe0052..de189e6f51c 100644 --- a/addons/crm/wizard/crm_send_email.py +++ b/addons/crm/wizard/crm_send_email.py @@ -90,24 +90,24 @@ class crm_send_new_email(osv.osv_memory): body += '\n\n%s' % (case.user_id.signature) case_pool._history(cr, uid, [case], _('Send'), history=True, email=data['to'], details=body) - + email_from = (case.user_id and case.user_id.address_id and \ + case.user_id.address_id.email) or tools.config.get('email_from',False) flag = tools.email_send( - case.user_id.address_id.email, + email_from, emails, data['subject'], case_pool.format_body(body), attach=attach, reply_to=case.section_id.reply_to, - openobject_id=str(case.id), - subtype="html" - ) + openobject_id=str(case.id), + ) if flag: if data['state'] == 'unchanged': pass elif data['state'] == 'done': - case_pool.case_close(cr, uid, [data['id']]) + case_pool.case_close(cr, uid, [case.id]) elif data['state'] == 'pending': - case_pool.case_pending(cr, uid, [data['id']]) + case_pool.case_pending(cr, uid, [case.id]) cr.commit() # Commented because form does not close due to raise @@ -153,7 +153,7 @@ class crm_send_new_email(osv.osv_memory): if 'text' in fields: res.update({'text': case.description or ''}) if 'state' in fields: - res.update({'state': 'done'}) + res.update({'state': 'pending'}) return res def get_reply_defaults(self, cr, uid, fields, context=None): @@ -174,19 +174,21 @@ class crm_send_new_email(osv.osv_memory): model = hist.log_id.model_id.model model_pool = self.pool.get(model) case = model_pool.browse(cr, uid, hist.log_id.res_id) - if 'to' in fields: + if 'to' in fields and hist.email: res.update({'to': hist.email}) if 'text' in fields: - header = '-------- Original Message --------' - sender = 'From: ' + case.user_id.address_id.email - to = 'To: ' + hist.email - sentdate = 'Sent: ' + hist.date - desc = '\n' + hist.description + header = '-------- Original Message --------' + sender = 'From: %s' %(hist.email_from or tools.config.get('email_from',False)) + to = 'To: %s' % (hist.email) + sentdate = 'Sent: %s' % (hist.date) + desc = '\n%s'%(hist.description) original = [header, sender, to, sentdate, desc] original = '\n'.join(original) - res.update({'text': '\n\n' + original}) + res.update({'text': '\n\n%s'%(original)}) if 'subject' in fields: - res.update({'subject': case.name or ''}) + res.update({'subject': '[%s] %s' %(str(case.id), case.name or '')}) + #if 'state' in fields: + # res.update({'state': 'pending'}) return res def view_init(self, cr, uid, fields_list, context=None): diff --git a/addons/crm/wizard/crm_send_email_view.xml b/addons/crm/wizard/crm_send_email_view.xml index bc11edfec2b..ece20c89efd 100644 --- a/addons/crm/wizard/crm_send_email_view.xml +++ b/addons/crm/wizard/crm_send_email_view.xml @@ -12,11 +12,12 @@
- - + + + @@ -51,11 +52,12 @@ - - + + +