I am trying to create a wizard, launched from a button in res.partner's form view, which has two buttons on its footer (besides the 'cancel' one): the first one launches a method that does stuff inside the related res.partner record (but it's not important to the main problem); the second one opens the email form with precompiled values (again, from the related res.partner's recordset values).
My question is: how do I prevent the wizard from closing when I click on the "Send email" button which opens the email form, so that (after I've finished with email itself) I can go back to the wizard and click the "Execute action" button?
I am using Odoo 8 with Python 2.7.14.
My code:
1- the button that launches the wizard (from res.partner):
<button string="Execute action" type="action"
name="%(execute_action_wizard)d"
attrs="{'invisible': [('action_required', '=', False)]}"
class="oe_highlight"/>
2- the action that launches the wizard:
<record id="execute_action_wizard"
model="ir.actions.act_window">
<field name="name">Execute action</field>
<field name="res_model">
account.payment.action.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id"
ref="execute_action_wizard_form_view"/>
<field name="target">new</field>
</record>
3- the buttons within the wizard itself:
<button name="compute_execute_action"
string="Execute action"
class="oe_highlight"
type="object"/>
<button name="open_form_send_mail"
string="Send email"
class="oe_highlight"
type="object"
attrs="{'invisible':[('send_mail', '=', False)]}"/>
4- email form method:
@api.multi
def open_form_send_mail(self):
self.ensure_one()
template_id = self.email_template_id.id
partner_id = self._context['active_ids'][0]
compose_form_id = self.env.ref(
'mail.email_compose_message_wizard_form', False).id
ctx = dict(
default_res_id=partner_id,
default_use_template=True,
default_template_id=template_id or False,
default_composition_mode='comment',
default_model='res.partner',
default_partner_ids=[(6, 0, [partner_id])],
default_subject=_(u"Client email")
)
return {
'name': _('Compose Email'),
'context': ctx,
'type': 'ir.actions.act_window',
'target': 'new',
'res_model': 'mail.compose.message',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'view_mode': 'form',
'view_type': 'form',
'flags': {'action_buttons': True},
}
Please help me out. This is driving me crazy.