bzr revid: rha@tinyerp.com-20110510135048-f044stg7gaij0867
This commit is contained in:
Rifakat Haradwala (Open ERP) 2011-05-10 19:20:48 +05:30
parent b89f923c8f
commit 5c0308f078
4 changed files with 22 additions and 20 deletions

View File

@ -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

View File

@ -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):

View File

@ -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')

View File

@ -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>