Allows the viewing of hierarchical models (i.e. parent-child relationships) directly in a tree view. Simply add the recursive attribute to the tree tag with `recursive="1"` or `recursive="true"` or `recursive="True"`. Parent-child field is autodetected from the model based on the _parent_name field which is standard in the Odoo ORM. Currently there is no option for expanding all children, but this may be added in future versions.
40 lines
1.7 KiB
XML
40 lines
1.7 KiB
XML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<odoo>
|
|
<!-- Extend List Renderer Header to Add Extra Column for Expand/Collapse Button Alignment -->
|
|
<t t-name="recursive_tree_view.Renderer" t-inherit="web.ListRenderer"
|
|
t-inherit-mode="extension">
|
|
<xpath expr="//th[hasclass('o_list_record_selector')]" position="before">
|
|
<th t-if="recursive"
|
|
class="o_recursive_expand_column cursor-default o_list_button">
|
|
<div style="min-width: 100px;"/>
|
|
</th>
|
|
</xpath>
|
|
</t>
|
|
|
|
<!-- Extend List Renderer Row to Add Expand/Collapse Button -->
|
|
<t t-name="web.ListRenderer.RecordRow" t-inherit="web.ListRenderer.RecordRow"
|
|
t-inherit-mode="extension">
|
|
<xpath expr="//tr[hasclass('o_data_row')]" position="after">
|
|
<t t-if="record.children && record.expanded">
|
|
<t t-foreach="record.children" t-as="record" t-key="record.id">
|
|
<t t-call="{{ constructor.recordRowTemplate }}"/>
|
|
</t>
|
|
</t>
|
|
</xpath>
|
|
<xpath expr="//td[1]" position="before">
|
|
<td t-if="this.recursive"
|
|
class="o_recursive_expand_column"
|
|
>
|
|
<button t-if="record.children"
|
|
t-att-data-expand="record.resId"
|
|
t-on-click.prevent="_onExpandClick"
|
|
t-att-data-depth="record.depth"
|
|
class="o_expand_button">
|
|
<span role="img"
|
|
t-att-class="'fa ' + (record.expanded ? 'fa-angle-down' : 'fa-angle-right')"
|
|
/>
|
|
</button>
|
|
</td>
|
|
</xpath>
|
|
</t>
|
|
</odoo>
|