Reputation: 81
When i add an image field in kanban view in odoo11 it has raised the error as "QWeb2 - template['kanban-box']: Runtime Error: TypeError: Cannot read property 'raw_value' of undefined" ". And the same code worked for me in odoo 9. I'm struck in identifying the cause of the issue. Here's my code.
Python Code:
class Test(models.Model):
_name = "test.test"
image = fields.Binary(attachment=True)
XML Code:
<record id = "test_id" model = "ir.ui.view">
<field name = "name">Test Image</field>
<field name = "model">test.test</field>
<field name = "arch" type = "xml">
<kanban>
<field name="image" />
<templates>
<t t-name="kanban-box">
<div class="oe_resource_vignette">
<div class="oe_resource_image">
<img t-att-src="kanban_image('test.test','image',record.id.raw_value)" class="oe_resource_picture"/>
</div>
</templates>
</kanban>
</field>
</record>
Thanks for your support and time.
Upvotes: 1
Views: 4183
Reputation: 311
You need to add the id
field to the kanban view (in any view) if you will be referencing it. This applies up to Odoo 14 as well.
Added <field name="id" attrs="{'invisible': True}"/>
to code below:
<record id = "test_id" model = "ir.ui.view">
<field name = "name">Test Image</field>
<field name = "model">test.test</field>
<field name = "arch" type = "xml">
<kanban>
<field name="image" />
<templates>
<t t-name="kanban-box">
<div class="oe_resource_vignette">
<div class="oe_resource_image">
<img t-att-src="kanban_image('test.test','image',record.id.raw_value)" class="oe_resource_picture"/>
</div>
</templates>
<field name="id" attrs="{'invisible': True}"/>
</kanban>
</field>
</record>
Kanban Docs: https://www.odoo.com/documentation/11.0/howtos/backend.html#kanban
Upvotes: 1
Reputation: 1
you can try it by adding the "id"
<record id = "test_id" model = "ir.ui.view">
<field name = "name">Test Image</field>
<field name = "model">test.test</field>
<field name = "arch" type = "xml">
<kanban>
<field name="id"/>
<field name="image"/>
<templates>
<t t-name="kanban-box">
<div class="oe_resource_vignette">
<div class="oe_resource_image">
<img t-att-src="kanban_image('test.test','image',record.id.raw_value)" class="oe_resource_picture"/>
</div>
</templates>
</kanban>
</field>
Upvotes: 0