我在客户发票中创建了一个名为“确认”的按钮。点击“确认”按钮后,“state1”将被“确认”。我想在'state1'='draft'时隐藏Validate按钮,并在'state1'='confirmed'时显示Validate按钮。我试过下面的代码,但它不起作用。任何人都可以帮助我吗?
<!-- inherit account invoice form -->
<record id="invoice_form_inheritai" model="ir.ui.view">
<field name="name">account.invoice.form.inheritai</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<button name="invoice_print" position="after">
<field name="state1" invisible="1"/>
<button name="invoice_check" string="Confirm" type="object" attrs="{'invisible': [('state1','not in', ['draft'])]}" class="oe_highlight" groups="base.group_user"/>
</button>
<button name="invoice_open" position="replace">
<button name="invoice_open" state="draft" string="Validate" attrs="{'invisible': [('state1','!=', ['confirmed'])]}" groups="base.group_user"/>
</button>
</field>
</record>
答案 0 :(得分:1)
<button name="invoice_open" string="Validate" attrs="{'invisible': [('state1','not in', ['confirmed']),('state','not in',['draft'])]}" groups="base.group_user"/>
请避免同时使用不可见的属性和状态。
答案 1 :(得分:0)
尝试使用“状态”而不是“状态”。甚至不需要attr。它会自动运行。例如:
<button name="invoice_open" states="confirmed" string="Validate" groups="base.group_user"/>