Reputation: 1043
I have many2many field:
supply_ids = fields.Many2many(comodel_name='supply.conditions',
relation='purchase_supply_rel',
column1='purchase_requests_id', column2='supply_conditions_id',
string='Supply Conditions')
and piece of xml
<page string="Order">
<field name="supply_ids"/>
</page>
I have only one supply.conditions form view but I want create another one (with less fields) and show it on supply_ids field click:
"Add object" -> "Create"
I don't know what method is called on "Add object" click or how can I select specific form view on "Add object" -> "Create" button..
Upvotes: 3
Views: 3670
Reputation: 14768
Create a second form view with like
<record id="view_supply_conditions_form2" model="ir.ui.view">
<field name="name">...</field>
<field name="model">supply.conditions</field>
<field name="priority">17</field>
<field name="arch" type="xml">
<!-- and so on -->
</field>
</record>
And then call it on your field with context:
<page string="Order">
<field name="supply_ids"
context="{'form_view_ref':'my_module.view_supply_conditions_form2'}"/>
</page>
Edit:
The corresponding context keys for list and search views are tree_view_ref
and search_view_ref
.
Thanks to @Fractalf
Upvotes: 7
Reputation: 1043
I found a solution, added context to field:
<page string="Order">
<field name="supply_ids" context="{'form_view_ref':'my_app_name.view_supply_conditions_form'}"/>/>
</page>
view_supply_conditions_form - new form view
Upvotes: 2