如何使按钮在 odoo 10 中不可见

How to make a button invisible in odoo 10

我正试图将此按钮隐藏在销售模块下。所以这是原始代码:

    <button name="%(action_view_sale_advance_payment_inv)d" 
              string="Create Invoice"
              type="action" class="btn-primary"
              attrs="{'invisible': [('invoice_status', '!=', 'to invoice')]}"/>

所以我继承了视图并创建了这段代码:

    <xpath name="//header/button[@name='%(sale.action_view_sale_advance_payment_inv)d']" position="attributes"> 
            <attribute name="invisible">1</attribute> 
    </xpath>

但是当运行这段代码时我得到了这个错误:

raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
ParseError: "Error while validating constraint

Argument must be bytes or unicode, got 'NoneType'

请帮忙。谢谢

您将 name 而不是 expr 作为 xpath 的属性:

<xpath expr="//header/button[@name='%(sale.action_view_sale_advance_payment_inv)d']" position="attributes"> 
    <attribute name="invisible">1</attribute> 
</xpath>

应该是这个问题。