Python 在销售订单表单上隐藏基于状态的锁定按钮&;odoo10中的条件
我正在使用Odoo10社区,我正在尝试继承销售订单表单和编辑锁定按钮,以使其仅在state=sale和我自己的条件下可见(基于其他字段值Python 在销售订单表单上隐藏基于状态的锁定按钮&;odoo10中的条件,python,xml,xpath,odoo-10,Python,Xml,Xpath,Odoo 10,我正在使用Odoo10社区,我正在尝试继承销售订单表单和编辑锁定按钮,以使其仅在state=sale和我自己的条件下可见(基于其他字段值('Costum_field','=','Value1')) 销售模块中的原始代码: <button name="action_done" type="object" string="Lock" states="sale" help="If the sale is locked, you can not modify it anymore. How
('Costum_field','=','Value1')
)
销售模块中的原始代码:
<button name="action_done" type="object" string="Lock" states="sale"
help="If the sale is locked, you can not modify it anymore. However, you will still be able to invoice or deliver."/>
<field name="state" widget="statusbar" statusbar_visible="draft,sent,sale"/>
这是我的代码:
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_done']" position="attributes">
<attribute name="states" /> <!-- delete states attribute, it's influencing invisible behaviour -->
<attribute name="invisible">['|' , ('state','!=', 'sale'), ('Costum_field','=', 'Value1')]</attribute>
</xpath>
</field>
['|',('state','!=','sale'),('Costum_field','=','Value1')]
现在,无论状态和我的服装字段值如何,按钮都是不可见的
感谢您的帮助为了在字段、按钮或其他表单元素上设置条件动态属性,您应该依赖于
attrs
字段的属性
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_done']" position="attributes">
<attribute name="states" /> <!-- delete states attribute, it's influencing invisible behaviour -->
<attribute name="attrs">{'invisible': ['|' , ('state','!=', 'sale'), ('Costum_field','=', 'Value1')]}</attribute>
</xpath>
</field>