Odoo如何为许多用户群提供访问按钮?

时间:2017-10-06 08:52:39

标签: python xml openerp odoo-10

我正在尝试允许两组用户访问以下代码:

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

然而,这不起作用?

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

1 个答案:

答案 0 :(得分:3)

您对给定组的语法错误。

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

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