Skip to Content
Menu
This question has been flagged
3 Replies
10574 Views

In Odoo, if I have a One2many field on an object

related_ids = fields.One2many("related.table", "inverse_id", "Related field")

I can define a form field for it:

<field name="related_ids" mode="tree" />

and the related records will show up as an inline list.

However, "related.table" has several tree views defined for it, and I want to use a specific one. Can I somehow specify which view I want shown?

Avatar
Discard

For example

<field name="bank_ids" >

<tree string="Bank Details">

<field name="state" />

<field name="sequence"/>

<field name="acc_number"/>

<field name="bank_name"/>

<field name="owner_name"/>

</tree>

</field>

Best Answer

<field name="related_ids" context="{'tree_view_ref' : 'your_module_folder.your_specific_tree_view'}"/>

Hope it can help you.


Avatar
Discard
Best Answer

Here is an example for you,

/addons/hr_timesheet/views/project_views.xml line#89

Screenshot from 2020-02-06 15-59-12.png
Here you can see both tree and kanban views of timesheet entries are defined inside the form view of tasks.
So you have to do the same.


Avatar
Discard
Related Posts Replies Views Activity
5
Aug 24
42964
2
Apr 24
948
3
Jun 23
3114
2
Jun 23
2357
3
Mar 23
8618