Mostafa Mostafa - 3 months ago 58
Python Question

How to access one2many fields values on Kanban view odoo 0.8?

I need to loop over the records of o2m filed in kanban to show what I need from the other model.

all i need in kanban view to do this

<t t-foreach="o2m_field" t-as"record">
<t t-esc="record.name"/>
</t>


Is that possible to do it?

Answer

Yes you can.

This question is a duplicate to Is it possible to show an One2many field in a kanban view in Odoo? but here is a link to a module from Serpent Consulting which will be able to do what you are looking for.

https://apps.openerp.com/apps/modules/8.0/web_one2many_kanban/

Here is a little more info.

<kanban>
    <field name="one2manyFieldname"/>
    <templates>
        <t t-name="kanban-box">
            <div class="oe_kanban_content">
                <p>
                   <t t-foreach="record.one2manyFieldname.raw_value" t-as='o'>
                       <t t-esc="o.name"/><br/>
                   </t>
                </p>
            </div>
        </t>
    </templates>
</kanban>

The important part is before the template tag you have to pass through your one2many field so it is available within your template. Then you must access the record's "raw_value" and give it an alias. Like this.

 <t t-foreach="record.attendee_ids.raw_value" t-as='o'>

Then you can access the properties of the record.

Comments