[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
This commit is contained in:
Hans Henrik Gabelgaard 2016-05-06 09:32:19 +02:00 committed by Martin Trigaux
parent c7fc8e1722
commit 638989b84e
No known key found for this signature in database
GPG Key ID: 7B0E288E7C0F83A7
1 changed files with 6 additions and 7 deletions

View File

@ -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