Ravi Gohil (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-576491-rgo 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-576491-rgo/+merge/113912

Hello,

Steps to reproduce:
1) Install account module,
2) go to Settings/Configuration/Email/Templates and open template named 
'Automated Invoice Notification Mail',and in 'Advanced' tab, click on 'Add 
sidebar button',
3) Go to Accounting/Customers/Customer Invoices form view and run the Wizard 
'Send Mail' and click on 'Send'.

The sent email will have a button 'View Invoice' clicking on which suppose to 
open the Invoice, instead it does nothing as the link isn't being set. 

Same issue is with Sale and Purchase module.

This fix fixes this issue for all Three modules, kindly review it.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-576491-rgo/+merge/113912
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-576491-rgo.
=== modified file 'edi/models/edi.py'
--- edi/models/edi.py	2012-01-13 11:17:36 +0000
+++ edi/models/edi.py	2012-07-09 07:12:20 +0000
@@ -681,5 +681,29 @@
         self._edi_import_attachments(cr, uid, record_id, edi_document, context=context)
 
         return record_id
+    
+class mail_compose_message(osv.osv_memory):
+    _inherit = 'mail.compose.message'
+    def send_mail(self, cr, uid, ids, context=None):
+        if context.get('mail.compose.message.mode') == 'mass_mail':
+            mail = self.browse(cr, uid, ids[0], context=context)
+            if context.get('active_ids') and context.get('active_model'):
+                active_ids = context['active_ids']
+                active_model = context['active_model']
+            else:
+                active_model = mail.model
+                active_model_pool = self.pool.get(active_model)
+                active_ids = active_model_pool.search(cr, uid, ast.literal_eval(mail.filter_id.domain), context=ast.literal_eval(mail.filter_id.context))
+
+            if active_model in ['account.invoice', 'sale.order', 'purchase.order']:
+                web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
+                for active_id in active_ids:
+                    edi_record = self.pool.get(active_model).browse(cr, uid, active_id, context=context)
+                    edi_token = self.pool.get('edi.document').export_edi(cr, uid, [edi_record], context = context)[0]
+                    ctx = dict(context, edi_web_url_view=EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token))
+                    ctx['active_ids'] = [active_id]
+                    super(mail_compose_message, self).send_mail(cr, uid, ids, context=ctx)
+                return {'type': 'ir.actions.act_window_close'}
+        return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'mail/wizard/mail_compose_message.py'
--- mail/wizard/mail_compose_message.py	2012-03-08 15:56:50 +0000
+++ mail/wizard/mail_compose_message.py	2012-07-09 07:12:20 +0000
@@ -216,13 +216,13 @@
                     active_ids = active_model_pool.search(cr, uid, ast.literal_eval(mail.filter_id.domain), context=ast.literal_eval(mail.filter_id.context))
 
                 for active_id in active_ids:
-                    subject = self.render_template(cr, uid, mail.subject, active_model, active_id)
-                    rendered_body = self.render_template(cr, uid, body, active_model, active_id)
-                    email_from = self.render_template(cr, uid, mail.email_from, active_model, active_id)
-                    email_to = self.render_template(cr, uid, mail.email_to, active_model, active_id)
-                    email_cc = self.render_template(cr, uid, mail.email_cc, active_model, active_id)
-                    email_bcc = self.render_template(cr, uid, mail.email_bcc, active_model, active_id)
-                    reply_to = self.render_template(cr, uid, mail.reply_to, active_model, active_id)
+                    subject = self.render_template(cr, uid, mail.subject, active_model, active_id, context)
+                    rendered_body = self.render_template(cr, uid, body, active_model, active_id, context)
+                    email_from = self.render_template(cr, uid, mail.email_from, active_model, active_id, context)
+                    email_to = self.render_template(cr, uid, mail.email_to, active_model, active_id, context)
+                    email_cc = self.render_template(cr, uid, mail.email_cc, active_model, active_id, context)
+                    email_bcc = self.render_template(cr, uid, mail.email_bcc, active_model, active_id, context)
+                    reply_to = self.render_template(cr, uid, mail.reply_to, active_model, active_id, context)
 
                     # in mass-mailing mode we only schedule the mail for sending, it will be 
                     # processed as soon as the mail scheduler runs.

_______________________________________________
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

Reply via email to