[IMP]: Improvements in crm for add cc wizard, included the last sent mail in communication history instead of case description
bzr revid: rpa@tinyerp.com-20091105134243-oh7fyurfs711uw5g
This commit is contained in:
parent
cba619bb37
commit
cfb5290996
|
@ -755,7 +755,7 @@ class crm_case(osv.osv):
|
|||
})
|
||||
return True
|
||||
|
||||
def __history(self, cr, uid, cases, keyword, history=False, email=False, context={}):
|
||||
def __history(self, cr, uid, cases, keyword, history=False, email=False, details=None, context={}):
|
||||
for case in cases:
|
||||
data = {
|
||||
'name': keyword,
|
||||
|
@ -769,7 +769,7 @@ class crm_case(osv.osv):
|
|||
obj = self.pool.get('crm.case.log')
|
||||
if history and case.description:
|
||||
obj = self.pool.get('crm.case.history')
|
||||
data['description'] = case.description
|
||||
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
|
||||
|
@ -1048,6 +1048,7 @@ class crm_email_add_cc_wizard(osv.osv_memory):
|
|||
'user_id': fields.many2one('res.users',"User"),
|
||||
'partner_id': fields.many2one('res.partner',"Partner"),
|
||||
'email': fields.char('Email', size=32),
|
||||
'subject': fields.char('Subject', size=32),
|
||||
}
|
||||
|
||||
def change_email(self, cr, uid, ids, user, partner):
|
||||
|
@ -1066,13 +1067,27 @@ class crm_email_add_cc_wizard(osv.osv_memory):
|
|||
|
||||
|
||||
def add_cc(self, cr, uid, ids, context={}):
|
||||
email = self.read(cr, uid, ids[0])['email']
|
||||
data = self.read(cr, uid, ids[0])
|
||||
email = data['email']
|
||||
subject = data['subject']
|
||||
|
||||
if not context:
|
||||
return {}
|
||||
history_line = self.pool.get('crm.case.history').browse(cr, uid, context['active_id'])
|
||||
crm_case = self.pool.get('crm.case')
|
||||
case_id = history_line.log_id.case_id.id
|
||||
crm_case.write(cr, uid, case_id, {'email_cc' : email})
|
||||
case = history_line.log_id.case_id
|
||||
body = history_line.description.replace('\n','\n> ')
|
||||
crm_case.write(cr, uid, case.id, {'email_cc' : email})
|
||||
flag = tools.email_send(
|
||||
case.user_id.address_id.email,
|
||||
[case.email_from],
|
||||
subject or '['+str(case.id)+'] '+case.name,
|
||||
crm_case.format_body(body),
|
||||
email_cc = [email],
|
||||
tinycrm=str(case.id)
|
||||
)
|
||||
if flag:
|
||||
cr.commit()
|
||||
return {}
|
||||
|
||||
crm_email_add_cc_wizard()
|
||||
|
|
|
@ -246,16 +246,15 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Add CC">
|
||||
<field name="name"/>
|
||||
<separator string="Test" colspan="4"/>
|
||||
<field name="subject"/>
|
||||
<separator string="" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="user_id"
|
||||
attrs="{ 'required' : [('name','=','user')]}"
|
||||
on_change="change_email(user_id, partner_id)"
|
||||
/>
|
||||
on_change="change_email(user_id, partner_id)"/>
|
||||
<field name="partner_id"
|
||||
attrs="{'required' : [('name','=','partner')]}"
|
||||
on_change="change_email(user_id, partner_id)"
|
||||
/>
|
||||
on_change="change_email(user_id, partner_id)"/>
|
||||
<field name="email"/>
|
||||
<button name="add_cc" string="Ok" type="object" icon="gtk-go-forward"/>
|
||||
</form>
|
||||
|
|
|
@ -73,7 +73,6 @@ def _mass_mail_send(self, cr, uid, data, context):
|
|||
case_pool=pool.get('crm.case')
|
||||
|
||||
case = case_pool.browse(cr,uid,data['ids'])[0]
|
||||
case_pool._history(cr, uid, [case], _('Send'), history=True, email=False)
|
||||
case_pool.write(cr, uid, [case.id], {
|
||||
'som': False,
|
||||
'canal_id': False,
|
||||
|
@ -85,6 +84,7 @@ def _mass_mail_send(self, cr, uid, data, context):
|
|||
raise wizard.except_wizard(_('Warning!'),("Please specify user's email address"))
|
||||
if case.user_id.signature:
|
||||
body += '\n\n%s' % (case.user_id.signature)
|
||||
case_pool._history(cr, uid, [case], _('Send'), history=True, email=False, details=body)
|
||||
flag = tools.email_send(
|
||||
case.user_id.address_id.email,
|
||||
emails,
|
||||
|
|
|
@ -85,7 +85,7 @@ def _get_info(self, cr, uid, data, context):
|
|||
raise wizard.except_wizard(_('Error'),_('You must put a Partner eMail to use this action!'))
|
||||
if not case.user_id:
|
||||
raise wizard.except_wizard(_('Error'),_('You must define a responsible user for this case in order to use this action!'))
|
||||
return {'to': case.email_from,'subject': '['+str(case.id)+'] '+case.name,'cc': case.email_cc or '', 'text': '> ' + case.description.replace('\n','\n> ')}
|
||||
return {'to': case.email_from,'subject': '['+str(case.id)+'] '+case.name,'cc': case.email_cc or '', 'text': '> ' + hist_obj.description.replace('\n','\n> ')}
|
||||
|
||||
class wizard_send_mail(wizard.interface):
|
||||
states = {
|
||||
|
|
Loading…
Reference in New Issue