Hello,
I have 1 custom class and there are fields in it. When I create kanban view for that, I am facing below error.
test.py :-
class Test(models.Model):
_name = 'test.test'
_description = 'Test'
name = fields.Char('Name')
product_id = fields.Many2one('product.product', 'Product')
image_medium = fields.Binary('Image', related='product_id.image_medium')
test_view.xml :-
<odoo>
<record id="test_kanban_view" model="ir.ui.view">
<field name="name">test.test.kanban.view</field>
<field name="model">test.test</field>
<field name="arch" type="xml">
<kanban>
<field name="name"/>
<field name="image_medium"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="oe_kanban_details">
<div class="row">
<div class="col-md-3">
<div class="o_kanban_image">
<img t-att-src="kanban_image('test.test','image_medium',record.id.raw_value)" alt="Image"/>
</div>
</div>
<div class="col-md-5">
<strong><field name="name"/></strong>
<div name="tags"/>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
</odoo>
Error :-
Uncaught TypeError: Cannot read property 'raw_value' of undefined
http://0.0.0.0:9898/web?debug#action=371&model=work.order&view_type=list&menu_id=241:16
Traceback:
TypeError: Cannot read property 'raw_value' of undefined
at Engine.eval (eval at _render (http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:3416:73), <anonymous>:16:120)
at Engine._render (http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:3415:296)
at Engine.render (http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:3415:151)
at Engine._render (http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:3419:57)
at Engine.render (http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:3415:151)
at Class._render (http://0.0.0.0:9898/web/content/373-51b7014/web.assets_backend.js:1780:132)
at Class.start (http://0.0.0.0:9898/web/content/373-51b7014/web.assets_backend.js:1770:1256)
at Class.prototype.(anonymous function) [as start] (http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:3537:488)
at http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:3682:52
at http://0.0.0.0:9898/web/content/341-db51ea1/web.assets_common.js:802:681
How can I solve this error ?
Any answer will be appreciable.
Thanks,
9 Answers
<odoo>
<record id="test_kanban_view" model="ir.ui.view">
<field name="name">test.test.kanban.view</field>
<field name="model">test.test</field>
<field name="arch" type="xml">
<kanban>
<field name="id"/>
<field name="name"/>
<field name="image_medium"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="oe_kanban_details">
<div class="row">
<div class="col-md-3">
<div class="o_kanban_image">
<img t-att-src="kanban_image('test.test','image_medium',record.id.raw_value)"/>
</div>
</div>
<div class="col-md-5">
<strong><field name="name"/></strong>
<div name="tags"/>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
</odoo>
hello, you need to place the product_id field before <template>
I have the same problem:
See how i solved it:
<kanban>
<field name="name"/>
<field name="estate_id"/>
<templates> <t t-name="kanban-box"> <div class="oe_kanban_global_click"> <div class="o_kanban_image">
<img t-att-src="kanban_image('estates.estate', 'image', record.estate_id.raw_value)" />
<div class="o_kanban_card_content"> <div class="oe_kanban_details">
<div><strong><field name="email"/></strong></div>
<div><field name="street"/></div>
<div><field name="mobile"/></div> <div><field name="phone"/></div> </div> </div> </div> </t> </templates>
</kanban>
estate_id is declared in my class
Hello,
you can Simply use in kanban view <field > tag instead of <img> tag. like see in below code.
<field name="image_medium" nolabel="1" widget="image" class="oe_right oe_avatar"/>
it's worked for me
Thanks.