I’m working on customizing a Kanban view in Odoo 17 where I need to iterate over a one2many field (container_ids) and display specific fields (like name and state) for each related record.
In Odoo 14, I used the following approach, which worked fine:
<t t-foreach="record.container_ids.raw_value" t-as="container">
<div class="yard_zone_container_ids_lines">
<t t-if="container.state == 'occupied'">
<button type="button" class="btn btn-danger oe_kanban_button"
t-att-data-id="container.id"
name="button_view_container_form">
<t t-esc="container.name"/>
</button>
</t>
<t t-elif="container.state == 'available'">
<button type="button" class="btn btn-success oe_kanban_button"
t-att-data-id="container.id"
name="button_view_container_form">
<t t-esc="container.name"/>
</button>
</t>
Kanban view in Odoo 14
When I try to implement the same logic the “.row_value” only returns the length of records. I also tried with better results but still can’t access the record values
<t t-foreach="record.container_ids.raw_value" t-as="container" t-key="container.id">
<div class="p-1 border">
<a class="btn btn-success"
t-att-data-id="container.id"
t-att-name="container.name">
<t t-esc="container.name"/>
</a>
</div>
</t>
Kanban view in Odoo 17
I also tried targeting “.value” and only container_ids and still not working.
Fares Alharbi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.