Merge lp:~openerp-dev/openobject-addons/6.1-opw-573332-skh into lp:openobject-addons/6.1

Proposed by Somesh Khare
Status: Rejected
Rejected by: Naresh(OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-573332-skh
Merge into: lp:openobject-addons/6.1
Diff against target: 74 lines (+19/-1)
2 files modified
email_template/email_template.py (+5/-0)
email_template/wizard/mail_compose_message.py (+14/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-573332-skh
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+103620@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

I am rejecting the fix for the following reasons:
As the Customer works with the patch provided and didn't ask explicitly to merge it into stable version
In fact its not necessary to merge it into stable version as 6.1 will not be maintained anymore after the release of v7.0

Thanks,
Naresh

Unmerged revisions

6766. By Somesh Khare

[FIX]email_template : Backported the code from trunk bug: 941428 for the issue of no attachment on email_template (Case: ref 57332)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
2222
23import base6423import base64
24import logging24import logging
25import time
2526
26import netsvc27import netsvc
27from osv import osv28from osv import osv
@@ -41,6 +42,7 @@
41 _name = "email.template"42 _name = "email.template"
42 _description = 'Email Templates'43 _description = 'Email Templates'
43 _rec_name = 'name' # override mail.message's behavior44 _rec_name = 'name' # override mail.message's behavior
45 _log = logging.getLogger('init')
4446
45 def render_template(self, cr, uid, template, model, res_id, context=None):47 def render_template(self, cr, uid, template, model, res_id, context=None):
46 """Render the given template text, replace mako expressions ``${expr}``48 """Render the given template text, replace mako expressions ``${expr}``
@@ -381,6 +383,9 @@
381 ir_attachment = self.pool.get('ir.attachment')383 ir_attachment = self.pool.get('ir.attachment')
382 values = self.generate_email(cr, uid, template_id, res_id, context=context)384 values = self.generate_email(cr, uid, template_id, res_id, context=context)
383 assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed'385 assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
386 values['user_id'] = uid
387 values['date'] = time.strftime("%Y-%m-%d %H:%M:%S")
388
384 attachments = values.pop('attachments') or {}389 attachments = values.pop('attachments') or {}
385 msg_id = mail_message.create(cr, uid, values, context=context)390 msg_id = mail_message.create(cr, uid, values, context=context)
386 # link attachments391 # link attachments
387392
=== 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 @@
20##############################################################################20##############################################################################
2121
22import base6422import base64
23import logging
2324
24from osv import osv25from osv import osv
25from osv import fields26from osv import fields
@@ -43,6 +44,7 @@
4344
44class mail_compose_message(osv.osv_memory):45class mail_compose_message(osv.osv_memory):
45 _inherit = 'mail.compose.message'46 _inherit = 'mail.compose.message'
47 _log = logging.getLogger('init')
4648
47 def _get_templates(self, cr, uid, context=None):49 def _get_templates(self, cr, uid, context=None):
48 """50 """
@@ -96,7 +98,7 @@
96 for fname, fcontent in attachment.iteritems():98 for fname, fcontent in attachment.iteritems():
97 data_attach = {99 data_attach = {
98 'name': fname,100 'name': fname,
99 'datas': fcontent,101 'datas': base64.b64encode(fcontent),
100 'datas_fname': fname,102 'datas_fname': fname,
101 'description': fname,103 'description': fname,
102 'res_model' : self._name,104 'res_model' : self._name,
@@ -160,4 +162,15 @@
160 def render_template(self, cr, uid, template, model, res_id, context=None):162 def render_template(self, cr, uid, template, model, res_id, context=None):
161 return self.pool.get('email.template').render_template(cr, uid, template, model, res_id, context=context)163 return self.pool.get('email.template').render_template(cr, uid, template, model, res_id, context=context)
162164
165 def send_mail(self, cr, uid, ids, context=None):
166 """Overrides 'mail.wizard' to use 'email.template' sending functionality.
167 """
168 for mail_compose in self.browse(cr, uid, ids, context=context):
169 res_id = context.get('active_id', False)
170
171 msg_id = self.pool.get('email.template').send_mail(cr, uid, mail_compose.template_id, res_id)
172 self._log.info('Message ID %s' % msg_id)
173
174 return {'type': 'ir.actions.act_window_close'}
175
163# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:176# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: