禁用基于条件的按钮在Odoo中? [英] Disable a button based on CONDITION in Odoo?

查看:161
本文介绍了禁用基于条件的按钮在Odoo中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据条件将具有属性的禁用类添加到字段?

How can i add disabled class with attributes to field based on CONDITION?

我尝试了以下方法,

1)

<t t-if="product.qty_available &lt;= 0">
    <attribute name="class">btn btn-primary btn-lg mt8 js_check_product a-submit disabled</attribute>
</t>


2)


2)

<attribute name="class" t-if="product.qty_available &gt; 0">btn btn-primary btn-lg mt8 js_check_product a-submit disabled</attribute>


3)


3)

<attribute name="class" >product.qty_available &gt; 0 and 'btn btn-primary btn-lg mt8 js_check_product a-submit' or 'btn btn-primary btn-lg mt8 js_check_product a-submit disabled'</attribute>


有人可以帮助我实现这一目标吗?


Can some one helping me to achieve this?

推荐答案

位置为"replace"的

Did with position="replace"

<xpath expr="//a[@id='add_to_cart']" position="replace">
      <a id="add_to_cart" t-attf-class="btn btn-primary btn-lg mt8 js_check_product a-submit #{product.qty_available &lt;= 0 and 'disabled'}" href="#" >Add to Cart</a>
  </xpath> 

这篇关于禁用基于条件的按钮在Odoo中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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