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
=== 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-12 07:11:19 +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
@@ -42,6 +43,8 @@
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
4445
46 _log = logging.getLogger('init')
47
45 def render_template(self, cr, uid, template, model, res_id, context=None):48 def render_template(self, cr, uid, template, model, res_id, context=None):
46 """Render the given template text, replace mako expressions ``${expr}``49 """Render the given template text, replace mako expressions ``${expr}``
47 with the result of evaluating these expressions with50 with the result of evaluating these expressions with
@@ -342,6 +345,7 @@
342 if template.report_template:345 if template.report_template:
343 report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context)346 report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context)
344 report_service = 'report.' + report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name347 report_service = 'report.' + report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name
348
345 # Ensure report is rendered using template's language349 # Ensure report is rendered using template's language
346 ctx = context.copy()350 ctx = context.copy()
347 if template.lang:351 if template.lang:
@@ -381,6 +385,9 @@
381 ir_attachment = self.pool.get('ir.attachment')385 ir_attachment = self.pool.get('ir.attachment')
382 values = self.generate_email(cr, uid, template_id, res_id, context=context)386 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'387 assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
388 values['user_id'] = uid
389 values['date'] = time.strftime("%Y-%m-%d %H:%M:%S")
390
384 attachments = values.pop('attachments') or {}391 attachments = values.pop('attachments') or {}
385 msg_id = mail_message.create(cr, uid, values, context=context)392 msg_id = mail_message.create(cr, uid, values, context=context)
386 # link attachments393 # link attachments
387394
=== modified file 'email_template/wizard/mail_compose_message.py'
--- email_template/wizard/mail_compose_message.py 2012-03-22 14:11:04 +0000
+++ email_template/wizard/mail_compose_message.py 2012-04-12 07:11:19 +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,8 @@
43class mail_compose_message(osv.osv_memory):44class mail_compose_message(osv.osv_memory):
44 _inherit = 'mail.compose.message'45 _inherit = 'mail.compose.message'
4546
47 _log = logging.getLogger('init')
48
46 def _get_templates(self, cr, uid, context=None):49 def _get_templates(self, cr, uid, context=None):
47 """50 """
48 Return Email Template of particular Model.51 Return Email Template of particular Model.
@@ -95,7 +98,7 @@
95 for fname, fcontent in attachment.iteritems():98 for fname, fcontent in attachment.iteritems():
96 data_attach = {99 data_attach = {
97 'name': fname,100 'name': fname,
98 'datas': fcontent,101 'datas': base64.b64encode(fcontent),
99 'datas_fname': fname,102 'datas_fname': fname,
100 'description': fname,103 'description': fname,
101 'res_model' : self._name,104 'res_model' : self._name,
@@ -159,4 +162,14 @@
159 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):
160 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)
161164
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'}
162# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:175# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches

to all changes: