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
1=== modified file 'email_template/email_template.py'
2--- email_template/email_template.py 2012-03-22 14:11:53 +0000
3+++ email_template/email_template.py 2012-04-26 07:21:18 +0000
4@@ -22,6 +22,7 @@
5
6 import base64
7 import logging
8+import time
9
10 import netsvc
11 from osv import osv
12@@ -41,6 +42,7 @@
13 _name = "email.template"
14 _description = 'Email Templates'
15 _rec_name = 'name' # override mail.message's behavior
16+ _log = logging.getLogger('init')
17
18 def render_template(self, cr, uid, template, model, res_id, context=None):
19 """Render the given template text, replace mako expressions ``${expr}``
20@@ -381,6 +383,9 @@
21 ir_attachment = self.pool.get('ir.attachment')
22 values = self.generate_email(cr, uid, template_id, res_id, context=context)
23 assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
24+ values['user_id'] = uid
25+ values['date'] = time.strftime("%Y-%m-%d %H:%M:%S")
26+
27 attachments = values.pop('attachments') or {}
28 msg_id = mail_message.create(cr, uid, values, context=context)
29 # link attachments
30
31=== modified file 'email_template/wizard/mail_compose_message.py'
32--- email_template/wizard/mail_compose_message.py 2012-03-23 15:46:38 +0000
33+++ email_template/wizard/mail_compose_message.py 2012-04-26 07:21:18 +0000
34@@ -20,6 +20,7 @@
35 ##############################################################################
36
37 import base64
38+import logging
39
40 from osv import osv
41 from osv import fields
42@@ -43,6 +44,7 @@
43
44 class mail_compose_message(osv.osv_memory):
45 _inherit = 'mail.compose.message'
46+ _log = logging.getLogger('init')
47
48 def _get_templates(self, cr, uid, context=None):
49 """
50@@ -96,7 +98,7 @@
51 for fname, fcontent in attachment.iteritems():
52 data_attach = {
53 'name': fname,
54- 'datas': fcontent,
55+ 'datas': base64.b64encode(fcontent),
56 'datas_fname': fname,
57 'description': fname,
58 'res_model' : self._name,
59@@ -160,4 +162,15 @@
60 def render_template(self, cr, uid, template, model, res_id, context=None):
61 return self.pool.get('email.template').render_template(cr, uid, template, model, res_id, context=context)
62
63+ def send_mail(self, cr, uid, ids, context=None):
64+ """Overrides 'mail.wizard' to use 'email.template' sending functionality.
65+ """
66+ for mail_compose in self.browse(cr, uid, ids, context=context):
67+ res_id = context.get('active_id', False)
68+
69+ msg_id = self.pool.get('email.template').send_mail(cr, uid, mail_compose.template_id, res_id)
70+ self._log.info('Message ID %s' % msg_id)
71+
72+ return {'type': 'ir.actions.act_window_close'}
73+
74 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: