Merge lp:~openerp-dev/openobject-addons/trunk-bug-941428-kjo into lp:openobject-addons

Proposed by Kuldeep Joshi(OpenERP)
Status: Rejected
Rejected by: Thibault Delavallée (OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-941428-kjo
Merge into: lp:openobject-addons
Diff against target: 83 lines (+21/-1)
2 files modified
email_template/email_template.py (+7/-0)
email_template/wizard/mail_compose_message.py (+14/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-941428-kjo
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+101692@code.launchpad.net

Description of the change

[FIX] Email is send without attachment in email_template

To post a comment you must log in.
Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Hello,

The bug has been fixed in trunk when refactoring a bit the EDI. Please refer to the bug description for a more detailed discussion. I t herefore reject this merge proposal.

Best regards,

Thibault.

Unmerged revisions

6724. By Mykola Lys

[FIX]email_template: set attachment to mail

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-12 07:11:19 +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@@ -42,6 +43,8 @@
13 _description = 'Email Templates'
14 _rec_name = 'name' # override mail.message's behavior
15
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 with the result of evaluating these expressions with
21@@ -342,6 +345,7 @@
22 if template.report_template:
23 report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context)
24 report_service = 'report.' + report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name
25+
26 # Ensure report is rendered using template's language
27 ctx = context.copy()
28 if template.lang:
29@@ -381,6 +385,9 @@
30 ir_attachment = self.pool.get('ir.attachment')
31 values = self.generate_email(cr, uid, template_id, res_id, context=context)
32 assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
33+ values['user_id'] = uid
34+ values['date'] = time.strftime("%Y-%m-%d %H:%M:%S")
35+
36 attachments = values.pop('attachments') or {}
37 msg_id = mail_message.create(cr, uid, values, context=context)
38 # link attachments
39
40=== modified file 'email_template/wizard/mail_compose_message.py'
41--- email_template/wizard/mail_compose_message.py 2012-03-22 14:11:04 +0000
42+++ email_template/wizard/mail_compose_message.py 2012-04-12 07:11:19 +0000
43@@ -20,6 +20,7 @@
44 ##############################################################################
45
46 import base64
47+import logging
48
49 from osv import osv
50 from osv import fields
51@@ -43,6 +44,8 @@
52 class mail_compose_message(osv.osv_memory):
53 _inherit = 'mail.compose.message'
54
55+ _log = logging.getLogger('init')
56+
57 def _get_templates(self, cr, uid, context=None):
58 """
59 Return Email Template of particular Model.
60@@ -95,7 +98,7 @@
61 for fname, fcontent in attachment.iteritems():
62 data_attach = {
63 'name': fname,
64- 'datas': fcontent,
65+ 'datas': base64.b64encode(fcontent),
66 'datas_fname': fname,
67 'description': fname,
68 'res_model' : self._name,
69@@ -159,4 +162,14 @@
70 def render_template(self, cr, uid, template, model, res_id, context=None):
71 return self.pool.get('email.template').render_template(cr, uid, template, model, res_id, context=context)
72
73+ def send_mail(self, cr, uid, ids, context=None):
74+ """Overrides 'mail.wizard' to use 'email.template' sending functionality.
75+ """
76+ for mail_compose in self.browse(cr, uid, ids, context=context):
77+ res_id = context.get('active_id', False)
78+
79+ msg_id = self.pool.get('email.template').send_mail(cr, uid, mail_compose.template_id, res_id)
80+ self._log.info('Message ID %s' % msg_id)
81+
82+ return {'type': 'ir.actions.act_window_close'}
83 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches

to all changes: