【问题标题】:How to make an existing button invisible only for specific group. Odoo 14如何使现有按钮仅对特定组不可见。奥多 14
【发布时间】:2021-06-27 20:09:58
【问题描述】:

我想让模型“account.move”中的“Reset To Draft”按钮仅对'account.group_account_invoice'可见,也就是说,它应该是不可见的对于组'account.group_account_manager',这是我的代码;

   <record id="account_move_form_view_extend" model="ir.ui.view">
            <field name="name">account.move.form.view.extend</field>
            <field name="model">account.move</field>
            <field name="inherit_id" ref="account.view_move_form"/>
            <field name="arch" type="xml">
             <xpath expr="//header//button[@name='button_draft']" position="attributes"/>
                <attribute name="groups">account.group_account_manager</attribute><xpath/>
                <attribute  name ="attrs=">{'invisible' : [('show_reset_to_draft_button', '=', True)]}</attribute>
            </field>
        </record>

但我收到了这个错误:

 raise ValueError(formatted_message).with_traceback(from_traceback) from from_exception
odoo.exceptions.ValidationError: Error while validating view:

Element '<attribute name="groups">' cannot be located in parent view

View name: account.move.form.view.extend

请问怎么了?我该怎么做 ? 谢谢。

【问题讨论】:

  • 你在这一行犯了错误 - account.group_account_manager。您必须在第二个属性标记完成后关闭 。

标签: javascript python xml odoo


【解决方案1】:

您对视图的定义不正确。这就是它的纠正方式。

<record id="account_move_form_view_extend" model="ir.ui.view">
    <field name="name">account.move.form.view.extend</field>
    <field name="model">account.move</field>
    <field name="inherit_id" ref="account.view_move_form"/>
    <field name="arch" type="xml">
         <xpath expr="//header//button[@name='button_draft']" position="attributes">
            <attribute name="groups">account.group_account_manager</attribute>
            <attribute name="attrs">{'invisible' : [('show_reset_to_draft_button', '=', True)]}</attribute>
         </xpath>
    </field>
</record>

【讨论】:

  • 此代码使两个组的“重置为草稿”按钮不可见:“group_account_invoice”和“group_account_manager”。我只想显示它:'account.group_account_invoice',请问有什么问题吗? @Dipen Shah
  • 使用 groups="" 你不能这样做。 group_account_manager 在 group_account_invoice 上面,如果普通用户看到,经理也看到。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-28
  • 2017-03-26
  • 2012-11-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多