Odoo 10-看板的有条件隐藏/显示视图图像 [英] Odoo 10 - Conditional hide/show of kanban view image

查看:395
本文介绍了Odoo 10-看板的有条件隐藏/显示视图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据default_code字段的状态隐藏产品图片. 如果default_code为空,我想将其隐藏.如果没有,我想显示图像.

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>

基本上什么都不做.

应在<img>标签上添加哪些内容,以便根据default_code字段显示或隐藏图像?

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

推荐答案

您可以将条件设​​置为t-if

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>

这篇关于Odoo 10-看板的有条件隐藏/显示视图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆