[IMP] email.message.common: implemented active_id and active_model in default_get() and fix reference of fields subject and body

bzr revid: rha@tinyerp.com-20110407125024-4354406jcb4ih2k9
This commit is contained in:
Rifakat Haradwala (Open ERP) 2011-04-07 18:20:24 +05:30
parent afc74ed47f
commit f53ee6053a
7 changed files with 21 additions and 19 deletions

View File

@ -38,10 +38,10 @@ class email_compose_message(osv.osv_memory):
model_obj = self.pool.get(model)
data = model_obj.browse(cr, uid , resource_id, context)
result.update({
'name' : data.name or False,
'subject' : data.name or False,
'email_to' : data.email_from or False,
'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
'description' : '\n' + (tools.ustr(data.user_id.signature or '')),
'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
'email_cc' : tools.ustr(data.email_cc or ''),
'model': model or False,
'res_id': resource_id or False,

View File

@ -75,7 +75,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
sender = 'From: %s' %(hist.email_from or '')
to = 'To: %s' % (hist.email_to or '')
sentdate = 'Date: %s' % (hist.date or '')
desc = '\n%s'%(hist.description)
desc = '\n%s'%(hist.body)
original = [header, sender, to, sentdate, desc]
original = '\n'.join(original)
return original

View File

@ -62,8 +62,8 @@ class email_compose_message(osv.osv_memory):
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
template_id = context.get('template_id', False)
vals = {}
if template_id and context.get('email_model') and context.get('email_res_id'):
vals = self.get_template_data(cr, uid, context.get('email_res_id'), template_id, context)
if template_id and context.get('active_model') and context.get('active_id'):
vals = self.get_template_data(cr, uid, context.get('active_id'), template_id, context)
if not vals:
return result
@ -116,8 +116,8 @@ class email_compose_message(osv.osv_memory):
message_pool = self.pool.get('email.message')
message_data = message_pool.browse(cr, uid, int(context.get('message_id')), context)
model = message_data.model
elif context.get('email_model',False):
model = context.get('email_model')
elif context.get('active_model',False):
model = context.get('active_model')
if model:
record_ids = email_temp_pool.search(cr, uid, [('model','=',model)])
return email_temp_pool.name_get(cr, uid, record_ids, context) + [(False,'')]

View File

@ -57,8 +57,8 @@ class email_compose_message(osv.osv_memory):
result.update({
'email_from': tools.config.get('email_from',''),
'email_to': record_data.user_to_review_id.work_email or False,
'name': _("Reminder to fill up Survey"),
'description': msg,
'subject': _("Reminder to fill up Survey"),
'body': msg,
'res_id': resource_id,
'email_cc': False,
'email_bcc': False,

View File

@ -33,12 +33,14 @@ class email_compose_message(osv.osv_memory):
context = {}
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
vals = {}
if context.get('email_model') and context.get('email_res_id'):
vals = self.get_value(cr, uid, context.get('email_model'), context.get('email_res_id'), context)
elif context.get('message_id', False):
vals = self.get_message_data(cr, uid, int(context.get('message_id', False)), context)
if context.get('active_model') and context.get('active_id') and not context.get('mail')=='reply':
vals = self.get_value(cr, uid, context.get('active_model'), context.get('active_id'), context)
elif context.get('mail')=='reply' and context.get('active_id', False):
vals = self.get_message_data(cr, uid, int(context.get('active_id', False)), context)
else:
result['model'] = context.get('email_model', False)
result['model'] = context.get('active_model', False)
if not vals:
return result
@ -213,7 +215,7 @@ class email_compose_message(osv.osv_memory):
message_id = mail.message_id
email_id = email_message_pool.schedule_with_attach(cr, uid, mail.email_from, mail.email_to, mail.subject, mail.body,
model=mail.model, email_cc=mail.email_cc, email_bcc=mail.email_bcc, reply_to=mail.reply_to,
attach=attachment, message_id=message_id, references=references, openobject_id=int(mail.res_id), debug=mail.debug,
attach=attachment, message_id=message_id, references=references, openobject_id=int(mail.res_id),
subtype=mail.sub_type, x_headers=mail.headers, priority=mail.priority, smtp_server_id=mail.smtp_server_id and mail.smtp_server_id.id, context=context)
email_ids.append(email_id)
return email_ids

View File

@ -54,9 +54,9 @@ class email_compose_message(osv.osv_memory):
if partner and len(partner.address):
result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email})
result.update({
'description': description or False,
'body': description or False,
'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False,
'name': _("Task '%s' Closed") % task_data.name,
'subject': _("Task '%s' Closed") % task_data.name,
'model': model,
'res_id': resource_id,
})

View File

@ -47,8 +47,8 @@ class email_compose_message(osv.osv_memory):
subject = _("Scrum Meeting : %s") %(meeting.date)
message = _("Hello , \nI am sending you Scrum Meeting : %s for the Sprint '%s' of Project '%s'") %(meeting.date, sprint.name, sprint.project_id.name)
result.update({
'name': subject,
'description': message,
'subject': subject,
'body': message,
'model': model,
'res_id': resource_id
})