result.update({
'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,
++ 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or tools.config.get('email_from', False),
'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
'email_cc' : tools.ustr(data.email_cc or ''),
'model': model or False,
mod_name = self.pool.get('ir.model').browse(cr, uid, model_id, context).model
return {'value':{'model':mod_name}}
++ def _lang_get(self, cr, uid, context={}):
++ obj = self.pool.get('res.lang')
++ ids = obj.search(cr, uid, [], context=context)
++ res = obj.read(cr, uid, ids, ['code', 'name'], context)
++ return [(r['code'], r['name']) for r in res] + [('','')]
++
_columns = {
'name': fields.char('Name', size=250),
'model_id':fields.many2one('ir.model', 'Resource'),
'model': fields.related('model_id', 'model', string='Model', type="char", size=128, store=True, readonly=True),
-- 'track_campaign_item':fields.boolean('Resource Tracking',
-- help="Enable this is you wish to include a special \
--tracking marker in outgoing emails so you can identify replies and link \
--them back to the corresponding resource record. \
--This is useful for CRM leads for example"),
-- 'lang':fields.char(
-- 'Language',
-- size=250,
-- help="The default language for the email."
++ 'lang': fields.selection(_lang_get, 'Language', size=5, help="The default language for the email."
" Placeholders can be used here. "
"eg. ${object.partner_id.lang}"),
'subject':fields.char(
'email_to': fields.char('To', size=256, help="Email Recipients. Placeholders can be used here."),
'email_cc': fields.char('Cc', size=256, help="Carbon Copy Email Recipients. Placeholders can be used here."),
'email_bcc': fields.char('Bcc', size=256, help="Blind Carbon Copy Email Recipients. Placeholders can be used here."),
-- 'message_id': fields.char('Message Id', size=1024, select=1, help="Message Id on Email. Placeholders can be used here."),
'reply_to':fields.char('Reply-To', size=250, help="Placeholders can be used here."),
'body': fields.text('Description', translate=True, help="Placeholders can be used here."),
'body_html': fields.text('HTML', help="Contains HTML version of email. Placeholders can be used here."),
'res_model': 'email.compose.message',
'src_model': src_obj,
'view_type': 'form',
- 'context': "{'email_model':'%s', 'email_res_id': active_id,'template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template.id),
- 'context': "{'template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template.id),
++ 'context': "{'template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (template.id),
'view_mode':'form,tree',
'view_id': res_id,
'target': 'new',
#'body_html': self.get_template_value(cr, uid, template.body_html, model, record_id, context),
}
-- if template.message_id:
-- # use provided message_id with placeholders
-- values.update({'message_id': self.get_template_value(cr, uid, template.message_id, model, record_id, context)})
--
-- elif template['track_campaign_item']:
-- # get appropriate message-id
-- values.update({'message_id': tools.generate_tracking_message_id(record_id)})
--
#Use signatures if allowed
if template.user_signature:
sign = self.pool.get('res.users').read(cr, uid, uid, ['signature'], context)['signature']
<separator string="Options" colspan="2"/>
<field name="lang" colspan="4" />
<field name="user_signature" colspan="4" />
-- <field name="track_campaign_item" colspan="4"/>
++ <field name="auto_delete"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Email Content"/>
<field name="ref_ir_value"/>
<button name="unlink_action" string="Delete Action" type="object" icon="gtk-delete" colspan="2" attrs="{'invisible':[('ref_ir_act_window','=',False), ('ref_ir_value','=',False)]}"/>
</group>
-- <group colspan="2" col="2">
-- <separator string="Advanced Options" colspan="2"/>
-- <field name="message_id"/>
-- <field name="auto_delete"/>
-- </group>
</group>
<group colspan="2" col="2">
<separator string="Attachments" colspan="2"/>
from osv import osv
from osv import fields
import tools
++from tools.translate import _
class email_compose_message(osv.osv_memory):
_name = 'email.compose.message'
vals.update(self.get_template_data(cr, uid, resource_id, template_id, context))
else:
vals.update({'attachment_ids' : []})
++ email_temp_pool = self.pool.get('email.template')
++ if context.get('active_model') and context.get('active_id') and email_temp_pool.browse(cr, uid, template_id, context=context).user_signature:
++ model_pool = self.pool.get(context['active_model'])
++ user = model_pool.browse(cr, uid, context['active_id'], context=context).user_id
++ signature = user and user.signature
++ vals['body'] = _('%s\n%s') %(vals['body'], signature or '')
return {'value': vals}
email_compose_message()
vals['email_cc'] = self.get_template_value(cr, uid, template.email_cc, model, res_id, context)
vals['email_bcc'] = self.get_template_value(cr, uid, template.email_bcc, model, res_id, context)
vals['reply_to'] = self.get_template_value(cr, uid, template.reply_to, model, res_id, context)
-- if template.message_id:
-- vals['message_id'] = self.get_template_value(cr, uid, message_id, model, res_id, context)
-- elif template.track_campaign_item:
-- vals['message_id'] = tools.generate_tracking_message_id(res_id)
vals['subject'] = self.get_template_value(cr, uid, template.subject, model, res_id, context)
description = self.get_template_value(cr, uid, template.body, model, res_id, context) or ''
if template.user_signature:
<field name="email_cc" readonly="1"/>
<field name="email_bcc" readonly="1"/>
<field name="reply_to" readonly="1"/>
-- <field name="message_id" readonly="1" attrs="{'invisible':[('message_id','=',False)]}" groups="base.group_extended"/>
<field name="subject" colspan="8" readonly="1"/>
</group>
<group col="4" colspan="4">
if 'smtp_server_id' in fields:
result['smtp_server_id'] = template.smtp_server_id.id
-- if 'message_id' in fields:
-- result['message_id'] = template.message_id
--
-- if 'track_campaign_item' in fields:
-- result['track_campaign_item'] = template.track_campaign_item
--
if 'attachment_ids' in fields:
result['attachment_ids'] = template_pool.read(cr, uid, template.id, ['attachment_ids'])['attachment_ids']
class email_message_common(osv.osv_memory):
_name = 'email.message.common'
_columns = {
-- 'subject':fields.text('Subject', translate=True),
++ 'subject':fields.text('Subject'),
'model': fields.char('Object Name', size=128, select=1),
'res_id': fields.integer('Resource ID', select=1),
'date': fields.datetime('Date'),
'sub_type': fields.char('Sub Type', size=32),
'headers': fields.text('x_headers'),
'priority':fields.integer('Priority'),
-- 'body': fields.text('Description', translate=True),
++ 'body': fields.text('Description'),
'body_html': fields.text('HTML', help="Contains HTML version of email"),
'smtp_server_id':fields.many2one('ir.mail_server', 'SMTP Server'),
}
msg_txt['message-id'] = message_id
_logger.info('Parsing Message without message-id, generating a random one: %s', message_id)
--
++
fields = msg_txt.keys()
msg['id'] = message_id
msg['message-id'] = message_id
subtype=message.sub_type,
x_headers=message.headers and eval(message.headers) or {},
priority=message.priority)
-- res = smtp_server_obj.send_email(cr, uid,
++ res = smtp_server_obj.send_email(cr, uid,
msg,
mail_server_id = message.smtp_server_id.id or None,
smtp_server=smtp_server and smtp_server.smtp_host or None,
_columns = {
'attachment_ids': fields.many2many('ir.attachment','email_message_send_attachment_rel', 'wizard_id', 'attachment_id', 'Attachments'),
++ 'auto_delete': fields.boolean('Auto Delete', help="Permanently delete emails after sending"),
}
def get_value(self, cr, uid, model, res_id, context=None):
'body' : description,
'subject' : subject,
'message_id' : message_data and message_data.message_id or False,
-- 'attachment_ids' : message_data and message_pool.read(cr, uid, message_id, ['attachment_ids'])['attachment_ids'] or [],
++ 'attachment_ids' : [],
'res_id' : message_data and message_data.res_id or False,
'email_from' : message_data and message_data.email_to or False,
'email_to' : message_data and message_data.email_from or False,
<form string="Reply Email">
<group col="6" colspan="4">
<field name="model" invisible="1"/>
-- <field name="smtp_server_id" widget="selection" colspan="4"/>
++ <field name="smtp_server_id" widget="selection" colspan="4" invisible="1"/>
<field name="email_from" colspan="4" required="1"/>
<field name="email_to" colspan="4" required="1"/>
<field name="email_cc" colspan="4"/>