簡體   English   中英

Odoo如何為“創建發票”按鈕設置用戶訪問權限組?

[英]Odoo How to set user access group for Create Invoice Button?

我嘗試在“創建發票”按鈕上分配用戶訪問組。 但是,它不起作用,並顯示以下錯誤消息。

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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM