parent
b89f923c8f
commit
5c0308f078
|
@ -45,7 +45,7 @@ class email_template(osv.osv):
|
|||
"Return Template Object"
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
|
||||
if not template_id:
|
||||
return False
|
||||
|
||||
|
@ -404,7 +404,7 @@ class email_template(osv.osv):
|
|||
# Add document attachments
|
||||
for attach in template.attachment_ids:
|
||||
#attach = attahcment_obj.browse(cr, uid, attachment_id, context)
|
||||
attachment[attach.datas_fname] = attach.datas
|
||||
attachment[attach.datas_fname] = base64.decodestring(attach.datas)
|
||||
values['attachment'] = attachment
|
||||
return values
|
||||
|
||||
|
|
|
@ -61,22 +61,24 @@ class email_compose_message(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
att_ids = []
|
||||
res_id = context.get('active_id', False)
|
||||
values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
||||
if values['attachment']:
|
||||
attachment = values['attachment']
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
for fname, fcontent in attachment.items():
|
||||
data_attach = {
|
||||
'name': fname,
|
||||
'datas': binascii.b2a_base64(str(fcontent)),
|
||||
'datas_fname': fname,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model' : self._name,
|
||||
'res_id' : ids and ids[0] or False
|
||||
}
|
||||
att_ids.append(attachment_obj.create(cr, uid, data_attach))
|
||||
values['attachment_ids'] = att_ids
|
||||
values = {}
|
||||
if template_id:
|
||||
res_id = context.get('active_id', False)
|
||||
values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
||||
if values['attachment']:
|
||||
attachment = values['attachment']
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
for fname, fcontent in attachment.items():
|
||||
data_attach = {
|
||||
'name': fname,
|
||||
'datas': binascii.b2a_base64(str(fcontent)),
|
||||
'datas_fname': fname,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model' : self._name,
|
||||
'res_id' : ids and ids[0] or False
|
||||
}
|
||||
att_ids.append(attachment_obj.create(cr, uid, data_attach))
|
||||
values['attachment_ids'] = att_ids
|
||||
return {'value': values}
|
||||
|
||||
def save_as_template(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -38,7 +38,7 @@ class email_template_preview(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
|
||||
template_id = context.get('active_id', False)
|
||||
template_id = context.get('template_id', False)
|
||||
if not template_id:
|
||||
return []
|
||||
template_pool = self.pool.get('email.template')
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<group col="4" colspan="4">
|
||||
<label string="" colspan="1"/>
|
||||
<button icon="gtk-close" special="cancel" string="Close"/>
|
||||
<button icon="gtk-ok" name="send_mail" string="Send now" type="object"/>
|
||||
<button icon="gtk-ok" name="send_mail" string="Send" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue