我试图根据default_code字段的状态隐藏产品图像。如果default_code为空,我想隐藏它。如果没有,我想显示图像。
到目前为止,我已经像这样修改了看板视图:
<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
字段的图像?
你可以像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>