diff options
| author | Thibault Delavallée <tde@openerp.com> | 2012-11-15 13:24:06 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2012-11-15 13:24:06 +0100 |
| commit | 81d4467c8fb4e15129d5dd6b8242fa1a8d4e5562 (patch) | |
| tree | 9d31c8cf67c3c1ff4d18e631063bb419c29e25d6 /addons | |
| parent | dfa48f425d55201ab4d22350819cec02e5b4a19a (diff) | |
[REV] mail.compose.message using email_template: _reopen is back, as the spec of a wizard should be that hitting a button close it. Therefore _reopen is necessaru to reopen the wizard with its previous value, to continue working on it.
bzr revid: tde@openerp.com-20121115122406-d88ozw5iclsqdyff
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/email_template/wizard/mail_compose_message.py | 28 | ||||
| -rw-r--r-- | addons/email_template/wizard/mail_compose_message_view.xml | 3 |
2 files changed, 22 insertions, 9 deletions
diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 129c32722f5..ba4cef83bdb 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -25,6 +25,21 @@ from osv import osv from osv import fields +def _reopen(self, res_id, 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, + }, + } + + class mail_compose_message(osv.TransientModel): _inherit = 'mail.compose.message' @@ -42,10 +57,8 @@ class mail_compose_message(osv.TransientModel): else: model = context.get('default_model', context.get('active_model')) - if model: - record_ids = email_template_obj.search(cr, uid, [('model', '=', model)], context=context) - return email_template_obj.name_get(cr, uid, record_ids, context) + [(False, '')] - return [] + record_ids = email_template_obj.search(cr, uid, [('model', '=', model)], context=context) + return email_template_obj.name_get(cr, uid, record_ids, context) + [(False, '')] def default_get(self, cr, uid, fields, context=None): if context is None: @@ -109,7 +122,7 @@ class mail_compose_message(osv.TransientModel): onchange_res['partner_ids'] = [(4, partner_id) for partner_id in onchange_res.pop('partner_ids', [])] onchange_res['attachment_ids'] = [(4, attachment_id) for attachment_id in onchange_res.pop('attachment_ids', [])] record.write(onchange_res) - return True + return _reopen(self, record.id, record.model) def onchange_use_template(self, cr, uid, ids, use_template, template_id, composition_mode, model, res_id, context=None): """ onchange_use_template (values: True or False). If use_template is @@ -141,8 +154,9 @@ class mail_compose_message(osv.TransientModel): 'attachment_ids': [(6, 0, [att.id for att in record.attachment_ids])] } template_id = email_template.create(cr, uid, values, context=context) - record.write({'template_id': template_id, 'use_template': True}) - return True + # record.write({'template_id': template_id, 'use_template': True}) + record.write(record.onchange_template_id(True, template_id, record.composition_mode, record.model, record.res_id)['value']) + return _reopen(self, record.id, record.model) #------------------------------------------------------ # Wizard validation and send diff --git a/addons/email_template/wizard/mail_compose_message_view.xml b/addons/email_template/wizard/mail_compose_message_view.xml index 0a530299d4a..5afaf9745e1 100644 --- a/addons/email_template/wizard/mail_compose_message_view.xml +++ b/addons/email_template/wizard/mail_compose_message_view.xml @@ -14,12 +14,11 @@ </xpath> <xpath expr="//footer" position="inside"> <group class="oe_right" col="1"> - <div>Use template + <div attrs="{'invisible':[('use_template','=',False)]}">Use template <field name="template_id" attrs="{'invisible':[('use_template','=',False)]}" nolabel="1" on_change="onchange_template_id(use_template, template_id, composition_mode, model, res_id, context)"/> </div> - or <button icon="/email_template/static/src/img/email_template_save.png" type="object" name="save_as_template" string="Save as new template" class="oe_link" help="Save as a new template" |
