Somesh Khare(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.1-opw-573332-skh into
lp:openobject-addons/6.1.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-573332-skh/+merge/103620
Hello Sir,
[Fix]: Issue : No attachment on email_template
Steps to reproduce the issue,
1. Go to Settings | Configuration | Email | Outgoing Mail Server |
2. Configure Email server
3. Go to Settings | Configuration | Email | Templates | Sale Order
4. Click on Advanced tab and Attach Report select "Quotation/ Order" and enter
Report FileName
5. Create Sale Order
6. E-Mail received without attachment
Expected behavior: Receive email should have Quotation/Order attachment.
Back-ported the code from the trunk.
Kindly review the branch and please share your views on it.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-573332-skh/+merge/103620
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.1-opw-573332-skh.
=== modified file 'email_template/email_template.py'
--- email_template/email_template.py 2012-03-22 14:11:53 +0000
+++ email_template/email_template.py 2012-04-26 07:21:18 +0000
@@ -22,6 +22,7 @@
import base64
import logging
+import time
import netsvc
from osv import osv
@@ -41,6 +42,7 @@
_name = "email.template"
_description = 'Email Templates'
_rec_name = 'name' # override mail.message's behavior
+ _log = logging.getLogger('init')
def render_template(self, cr, uid, template, model, res_id, context=None):
"""Render the given template text, replace mako expressions ``${expr}``
@@ -381,6 +383,9 @@
ir_attachment = self.pool.get('ir.attachment')
values = self.generate_email(cr, uid, template_id, res_id, context=context)
assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
+ values['user_id'] = uid
+ values['date'] = time.strftime("%Y-%m-%d %H:%M:%S")
+
attachments = values.pop('attachments') or {}
msg_id = mail_message.create(cr, uid, values, context=context)
# link attachments
=== modified file 'email_template/wizard/mail_compose_message.py'
--- email_template/wizard/mail_compose_message.py 2012-03-23 15:46:38 +0000
+++ email_template/wizard/mail_compose_message.py 2012-04-26 07:21:18 +0000
@@ -20,6 +20,7 @@
##############################################################################
import base64
+import logging
from osv import osv
from osv import fields
@@ -43,6 +44,7 @@
class mail_compose_message(osv.osv_memory):
_inherit = 'mail.compose.message'
+ _log = logging.getLogger('init')
def _get_templates(self, cr, uid, context=None):
"""
@@ -96,7 +98,7 @@
for fname, fcontent in attachment.iteritems():
data_attach = {
'name': fname,
- 'datas': fcontent,
+ 'datas': base64.b64encode(fcontent),
'datas_fname': fname,
'description': fname,
'res_model' : self._name,
@@ -160,4 +162,15 @@
def render_template(self, cr, uid, template, model, res_id, context=None):
return self.pool.get('email.template').render_template(cr, uid, template, model, res_id, context=context)
+ def send_mail(self, cr, uid, ids, context=None):
+ """Overrides 'mail.wizard' to use 'email.template' sending functionality.
+ """
+ for mail_compose in self.browse(cr, uid, ids, context=context):
+ res_id = context.get('active_id', False)
+
+ msg_id = self.pool.get('email.template').send_mail(cr, uid, mail_compose.template_id, res_id)
+ self._log.info('Message ID %s' % msg_id)
+
+ return {'type': 'ir.actions.act_window_close'}
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp