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,
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
<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>
Thank you so much for your answer. In odoo12, we have to define <field name="id"/> which is not compulsory in odoo10.
You are welcome
I had the same problem. solved by define id field in before <template/>
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.
Make your image field storable in DB, if its a related field.
image_medium = fields.Binary('Image', related='product_id.image_medium', store=True)
Thanks for your answer, but i still get same error after add store=True in field definition.
Hello @Hilar AK, I tried with remove related field but same issue occurs. Can you help me on this ? Thanks,
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
May 20
|
10004 | ||
|
2
May 20
|
5252 | ||
|
1
Feb 19
|
6065 | ||
|
0
Jan 19
|
5379 | ||
|
0
Apr 16
|
2158 |