Skip to Content
Menu
This question has been flagged
1 Reply
1908 Views

I've added a custom selection field in my module and I'd like to show a little icon depending on what is selected. I got all the icons showing up and the selection field working as expected, but the problem comes when I try and show only one icon at a time. Here's the code:

<span>
<
span t-if="record.order_type == 'delivery'" class="fa fa-bus"></span>
<
span t-if="record.order_type == 'store'" class="fa fa-cart-arrow-down"></span>
<
span t-if="record.order_type == 'online'" class="fa fa-laptop"></span>
</
span>
When I added the t-if attributes, nothing showed up. I looked around at other forum posts and at the xml for other kanban views and tried adding ".value" or ".raw_value" after order_type, but that only gave me an error:
Traceback:
TypeError: Cannot read property 'value' of undefined
at Engine.eval (eval at _render (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/534-fa1f61a/web.assets_common.js:4426:73), <anonymous>:181:32)
at Engine._render (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/534-fa1f61a/web.assets_common.js:4425:296)
at Engine.render (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/534-fa1f61a/web.assets_common.js:4425:151)
at Engine._render (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/534-fa1f61a/web.assets_common.js:4429:57)
at Engine.render (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/534-fa1f61a/web.assets_common.js:4425:151)
at Class._render (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/606-2e24acc/web.assets_backend.js:2489:561)
at Class.start (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/606-2e24acc/web.assets_backend.js:2481:1273)
at Class.prototype.<computed> [as start] (https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/534-fa1f61a/web.assets_common.js:4619:488)
at https://tfqoc-lumeprep2-customerflow-2129849.dev.odoo.com/web/content/534-fa1f61a/web.assets_common.js:4950:52
at async Promise.all (index 1)
So it looks like order_type is undefined on the model. However, this is a field that I added, so I know it exists.

I tried adding a t-if on the parent <span> with just "record.order_type" and nothing showed up at all.

So after trying all that, I'm left with one question: How do I access/check field values on my model with t-if?


Avatar
Discard
Best Answer

You have to add that field in the kanban view, right after you start <kanban> tag.

        

Avatar
Discard
Author

Yep, that was exactly it! Thanks for the quick response!

Related Posts Replies Views Activity
3
Aug 24
4713
1
Sep 22
1092
2
Sep 23
4075
0
Jul 21
94
1
May 21
1859