首页 > 解决方案 > 如何使现有按钮仅对特定组不可见。奥多 14

问题描述

我想让模型“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

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

标签: javascriptpythonxmlodoo

解决方案


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

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

推荐阅读