From 638989b84e1119e10e6b2f2d33aab683ceef4aa5 Mon Sep 17 00:00:00 2001 From: Hans Henrik Gabelgaard Date: Fri, 6 May 2016 09:32:19 +0200 Subject: [PATCH] [FIX] mail: keep recipients after saving a template When sending an email via the mail.compose wizard, the selected partners are stored in the context (`active_ids`). If the composed message is saved (button "save template"), the context is lost in the _reopen action. The active_ids content of the new context is the id of the newly created mail template and is used as the id of a res.partner (sending the email to a different contact). Keep the context during the reopen to avoid losing active_ids. Closes #11947 --- .../email_template/wizard/mail_compose_message.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 60b3b0d3af0..fcc4441abf1 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -23,18 +23,17 @@ from openerp import tools from openerp.osv import osv, fields -def _reopen(self, res_id, model): +def _reopen(self, res_id, model, context=None): + # save original model in context, because selecting the list of available + # templates requires a model in context + context = dict(context or {}, default_model=model) return {'type': 'ir.actions.act_window', 'view_mode': 'form', 'view_type': 'form', 'res_id': res_id, 'res_model': self._name, 'target': 'new', - # save original model in context, because selecting the list of available - # templates requires a model in context - 'context': { - 'default_model': model, - }, + 'context': context, } @@ -148,7 +147,7 @@ class mail_compose_message(osv.TransientModel): template_values = record.onchange_template_id(template_id, record.composition_mode, record.model, record.res_id)['value'] template_values['template_id'] = template_id record.write(template_values) - return _reopen(self, record.id, record.model) + return _reopen(self, record.id, record.model, context=context) #------------------------------------------------------ # Wizard validation and send