我想检查两个选择字段的值,然后使按钮不可见

时间:2018-04-18 04:06:14

标签: xml odoo odoo-10 odoo-view

我想检查两个选择字段的值,然后使按钮不可见。我试着这样:

  

代码

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="orchid_sale_order_cancel_request_inherit" model="ir.ui.view">
        <field name="name">sale_order_cancel_request</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
             <button name="action_cancel" position="after">
                <button string="Cancel Request" type="object" name="cancel_request" attrs="{'invisible':['&amp;',('od_dms','!=','sale'),('state','!=','sale')]}"/>
             </button>
        </field>
    </record>
</odoo>

此处od_dmsstate是两个选择字段。我想仅在action_cancel = od_dms和{{sale时显示按钮state 1}} = sale

1 个答案:

答案 0 :(得分:2)

在按钮中,attrs应为:

attrs="{'invisible':['|',('od_dms','!=','sale'),('state','!=','sale')]}"