Odoo 10 - Conditional hide/show of kanban view image

无人久伴 提交于 2019-12-23 05:32:19

问题


I am trying to hide the product image based on the status of default_code field. If default_code is empty, I want to hide it. If not, I want to show image.

So far I have modified the kanban view like this:

<record id="conditional_product_kanban_view" model="ir.ui.view">
    <field name="name">Kanban Extended View</field>
    <field name="inherit_id" ref="product.product_template_kanban_view"/>
    <field name="model">product.template</field>
    <field name="arch" type="xml">
        <xpath expr="//div[@class='o_kanban_image']" position="replace">
            <div class="o_kanban_image">
                <img t-att-src="kanban_image('product.template', 'image_small', record.id.value)"/>
            </div>                
        </xpath>
    </field>
</record>

which basically does nothing.

What shall be added to <img> tag so image is displayed or hidden based on default_code field?


回答1:


you can put into condition like t-if

<t t-if="record.default_code.value>
 <div class="o_kanban_image">
            <img t-att-src="kanban_image('product.template', 'image_small', record.id.value)"/>
        </div>
</t>


来源:https://stackoverflow.com/questions/48312125/odoo-10-conditional-hide-show-of-kanban-view-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!