Odoo 如何允许多组用户访问按钮?

Odoo How to allow access button for many group of user?

我正在尝试允许两组用户访问,如下代码所示:

<record model="ir.ui.view">
        <field name="name">sale.order.approve</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="/form/header/button[@name='action_approve']" position="replace">
                <!-- <field name="groups_id" eval="[(4,ref('group_lead')),(4,ref('group_sm'))]"/> -->
                <button name="action_approve" states="pending" string="Approve" class="btn-primary o_sale_confirm" type="object"  groups="[ref('group_lead'),ref('group_sm')]" />
            </xpath>
        </field>
    </record>

然而这不起作用?

你有解决这个问题的方法吗?

您对给定组的语法错误。

<record model="ir.ui.view">
    <field name="name">sale.order.approve</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <xpath expr="/form/header/button[@name='action_approve']" position="replace">
            <!-- <field name="groups_id" eval="[(4,ref('group_lead')),(4,ref('group_sm'))]"/> -->
            <button name="action_approve" states="pending" string="Approve" class="btn-primary o_sale_confirm" type="object"  groups="account.group_account_user,account.group_account_manager,account.group_account_invoice" />
        </xpath>
    </field>
</record>

这里我给了一个样本组,你可以添加你的。