Reputation: 3747
To specify, I am on the base.view_partner_form. I have inserted a new page there like this:
<record id="view_partner_get_Emails" model="ir.ui.view">
<field name="name">res.partner.property.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<page name="internal_notes" position="before">
<page string="Emails">
<field name="mail_message_lines" mode="tree" style="overflow:hidden;">
<tree string="Emails">
<field name="date" />
<field name="subject" />
<field name="partner_ids" />
<field name="cc" />
<field name="email_from" />
<field name="body" style="height: 40px; overflow:hidden;" />
</tree>
</field>
</page>
</page>
</field>
</record>
This page holds some emails that I have inserted on the mail.message table (many2many relationship between mail.message and res.partner)
On the click of any email, the mail.view_message_form opens up that has be modified by me as well (setting some fields read only).
My question is the following: When I click an email in a res.partner's form I want the ID of that partner to be passed along to the new form in the context of it. How can this be achieved?
Upvotes: 1
Views: 65
Reputation: 14801
Let me guess it right: you want to auto fill partner_ids? Try to set the current opened partner in context, like:
<field name="mail_message_lines" mode="tree" style="overflow:hidden;" context={'default_partner_ids':[active_id]}>...</field>
Upvotes: 1
Reputation: 14746
Your purpose will be resolved by defining inline form view there.
<page string="Emails">
<field name="mail_message_lines" mode="tree" style="overflow:hidden;">
<tree string="Emails">
<field name="date" />
<field name="subject" />
<field name="partner_ids" />
<field name="cc" />
<field name="email_from" />
<field name="body" style="height: 40px; overflow:hidden;" />
</tree>
<form string="Emails">
<field name="date" readonly="1" />
<field name="subject" readonly="1" />
<field name="partner_ids" readonly="1" />
<field name="cc" />
<field name="email_from" />
<field name="body" style="height: 40px; overflow:hidden;" />
</form>
</field>
</page>
No need to pass parameter to set fields readonly / invisible, however you can do this directly in inline view.
Click here to see one more answer.
Upvotes: 1