简体   繁体   English

Odoo如何为“创建发票”按钮设置用户访问权限组?

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

I try to assign user access group on Create Invoice Button. 我尝试在“创建发票”按钮上分配用户访问组。 However it doesn't work and show these following error msg. 但是,它不起作用,并显示以下错误消息。

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>

I don't know what happen. 我不知道会发生什么 I think my code is already correct. 我认为我的代码已经正确。

Do you have any suggestion?? 你有什么建议吗?

<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>

Your Xpath is not seem be to correct. 您的Xpath似乎不正确。 Please try the following 请尝试以下

<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