gpt4 book ai didi

python - Odoo 如何设置创建发票按钮的用户访问组?

转载 作者:行者123 更新时间:2023-12-01 02:32:32 26 4
gpt4 key购买 nike

我尝试在“创建发票”按钮上分配用户访问组。但是它不起作用并显示以下错误消息。

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>

最佳答案

您的 Xpath 似乎不正确。请尝试以下操作

<xpath expr="//button[@name='%(action_view_sale_advance_payment_inv)d']" position="attributes">
<attribute name="groups">wongnai_flow.group_lead</attribute>
</xpath>

关于python - Odoo 如何设置创建发票按钮的用户访问组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46644241/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com