我尝试在创建发票按钮上分配用户访问组。但是它不起作用并显示以下错误信息。
ParseError: "Error while validating constraint
Element '<xpath expr="//button[@name='239'][0]">' cannot be located in parent view
Error context:
View `sale.order.invoice`
[view_id: 547, xml_id: n/a, model: sale.order, parent_id: 509]
None" while parsing /mnt/extra-addons/self-addons/wongnai_flow/views/invoices/create_invoice.xml:3, near
<record model="ir.ui.view">
<field name="name">sale.order.invoice</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d'][0]" position="replace">
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice" type="action" class="btn-primary" attrs="{'invisible': [('invoice_status', '!=', 'to invoice')]}" groups="wongnai_flow.group_lead"/>
</xpath>
</field>
</record>
我不知道会发生什么。我认为我的代码已经正确了。
你有什么建议吗?
<record model="ir.ui.view">
<field name="name">sale.order.invoice</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d'][0]" position="replace">
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice"
type="action" class="btn-primary"
attrs="{'invisible': [('invoice_status', '!=', 'to invoice')]}"
groups="wongnai_flow.group_lead"/>
</xpath>
</field>
</record>
<record model="ir.ui.view">
<field name="name">sale.order.invoice</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d'][1]" position="replace">
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice"
type="action" context="{'default_advance_payment_method': 'percentage'}"
attrs="{'invisible': ['|',('invoice_status', '!=', 'no'), ('state', '!=', 'sale')]}"
groups="wongnai_flow.group_lead"/>
</xpath>
</field>
</record>
答案 0 :(得分:2)
你的Xpath似乎不正确。请尝试以下
<xpath expr="//button[@name='%(action_view_sale_advance_payment_inv)d']" position="attributes">
<attribute name="groups">wongnai_flow.group_lead</attribute>
</xpath>