[FIX+IMP] crm: crm send mail wizard
bzr revid: hmo@tinyerp.com-20100322073406-wr8masbwghfv0l3w
This commit is contained in:
+4
-3
@@ -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()
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
<form string="Send New Mail" col="2">
|
||||
<field name="to" />
|
||||
<field name="cc" />
|
||||
<field name="subject" />
|
||||
<field name="text" widget="text_tag"/>
|
||||
<field name="subject" />
|
||||
<field name="doc1" />
|
||||
<field name="doc2" />
|
||||
<field name="doc3" />
|
||||
<separator string="" colspan="4"/>
|
||||
<field name="text" nolabel="1" colspan="4"/>
|
||||
<separator colspan="4" string="Set case state to" />
|
||||
<field name="state" />
|
||||
<separator string=" " colspan="4"/>
|
||||
@@ -51,11 +52,12 @@
|
||||
<form string="Reply to last Mail" col="2">
|
||||
<field name="to" />
|
||||
<field name="cc" />
|
||||
<field name="subject" />
|
||||
<field name="text" widget="text_tag"/>
|
||||
<field name="subject" />
|
||||
<field name="doc1" />
|
||||
<field name="doc2" />
|
||||
<field name="doc3" />
|
||||
<separator string="" colspan="4"/>
|
||||
<field name="text" nolabel="1" colspan="4"/>
|
||||
<separator string=" " colspan="4"/>
|
||||
<group colspan="4" col="3" >
|
||||
<label string=" " />
|
||||
@@ -78,4 +80,4 @@
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user