Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在销售订单表单上隐藏基于状态的锁定按钮&;odoo10中的条件_Python_Xml_Xpath_Odoo 10 - Fatal编程技术网

Python 在销售订单表单上隐藏基于状态的锁定按钮&;odoo10中的条件

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

我正在使用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. 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>