I added a button to a form view of a model (event.event). This button redirects to the tree view of other model (event.registration). I am trying to pass a variable (event_id) from the first view to the second one.
Then, in the tree view of the model event_registration, I added a new option to the menu More (at the top of the page), using act_window. The option which I added redirects to the form view of another model (mail.compose.message).
What I need is to pass the variable event_id from the view of event.event to the view of mail.compose.message. How can I achieve this?
MODEL event.event:
XML
<record id="action_view_event_registers"
model="ir.actions.act_window">
<field name="name">View registers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">event.registration</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="context">{'event_id': context.get('event_id', False),}</field>
<field name="view_id" ref="event.view_event_registration_tree" />
<field name="target">current</field>
</record>
<record id="event_extended_form_view" model="ir.ui.view">
<field name="name">event.extended.form.view</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<field name="speaker_confirmed" position="after">
<button name="%(event_extended.action_view_event_registers)d"
string="View registers" type="action" icon="gtk-find"
context="{'event_id': active_id}"/>
</field>
</field>
</record>
MODEL event.registration:
XML
<act_window name="Invite partners to an event"
res_model="mail.compose.message"
src_model="event.registration"
view_mode="form"
multi="True"
target="new"
context="{'event_id': context.get('event_id'),}"
id="invite_partner_to_event"/>
MODEL mail.compose.message:
PY
def _default_template(self, cr, uid, context=None):
event_id = context.get('event_id', None)
_logger.info(event_id)
return False
_defaults = {
'template_id': _default_template,
}
As you can see, I'm doing nothing, only trying to print the event_id in the log file. However, it is returning None.
Can anybody help me here, please? I'm not sure if this is the right way to achieve my target.
No comments:
Post a Comment