本文介绍了Security.xml中的OpenERP ir.rule记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    <record model="ir.rule" id="stock_inventory_comp_rule">
        <field name="name">Inventory multi-company</field>
        <field name="model_id" ref="model_stock_inventory" />
        <field name="global" eval="True" />
        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
        </field>
    </record>

我对security.xml文件中的上述代码片段感到困惑这就是下面的标签的意思.?

id="stock_inventory_comp_rule"表示此行及其标记所在的位置.或者仅用于保存&保留用于通过ID标识记录的身份.?

<field name="name">Inventory multi-company</field>是这一行的意思.这仅用于显示目的吗?

<field name="model_id" ref="model_stock_inventory" />哪个是model_stock_inventory的意思,它的用途是什么??

<field name="global" eval="True" />为什么这将全局设置为True.如果我们将其设置为False,则预期结果是什么?

<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]此处在域中显示类似域过滤器.该标准设置为上述模型类吗?此片段的用途是什么?

解决方案

ir.rule与组一起使用,例如在销售订单中,您希望每个用户只看到自己的记录而不是其他用户销售订单,因此您可以ir.rule中的一条记录规则,以阻止其他用户查看彼此的销售订单,并将该规则分配给某个组(当您将该组分配给用户时,该规则会自动应用此规则)

示例

<record id="sale_order_user_rule" model="ir.rule">
            <field name="name">Quotations/Sale Orders</field>
            <field name="model_id" ref="sale.model_sale_order"/>
            <field name="domain_force">[('user_id','in',[user.id])]</field>
            <field name="groups" eval="[(4, ref('group_purcase_manager'))]"/>
            <field eval="1" name="perm_unlink"/>
            <field eval="1" name="perm_write"/>
            <field eval="1" name="perm_read"/>
            <field eval="1" name="perm_create"/>
        </record>

如您在示例中看到的,我创建了一个规则来限制其他用户查看彼此的记录并将此规则分配给团购经理,您可以通过此规则来限制用户访问权限,例如读取,写入,创建,删除等

像您的示例一样,您制定规则查看公司和他的孩子重新记录了所有记录全局意味着该规则适用于所有人,而无需对任何组进行认证

    <record model="ir.rule" id="stock_inventory_comp_rule">
        <field name="name">Inventory multi-company</field>
        <field name="model_id" ref="model_stock_inventory" />
        <field name="global" eval="True" />
        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
        </field>
    </record>

I'm confused with above code fragment in security.xml fileswhich is mean by below tags.?

id="stock_inventory_comp_rule" means of this line and where its tag with.or is it only for save & keep for identify records by id purpose.?

<field name="name">Inventory multi-company</field> mean by this line.is this only use for display purpose.?

<field name="model_id" ref="model_stock_inventory" /> which one is mean by model_stock_inventory and what is the usage of this .?

<field name="global" eval="True" /> why this one set global True.?if we set it as False then what will the expected result.?

<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] here shows like domain filter in fields.? is this criteria set to above mentioned model class.?what is the usage of this fragment.?

解决方案

ir.rule is used with groups, like in sale order you want a case that every user just see his own record not other user sale order, so you make a record rule in ir.rule to stop other user to see each other sale order, and assign this rule to some group when you assing this group to user it automatically apply this rule

Example

<record id="sale_order_user_rule" model="ir.rule">
            <field name="name">Quotations/Sale Orders</field>
            <field name="model_id" ref="sale.model_sale_order"/>
            <field name="domain_force">[('user_id','in',[user.id])]</field>
            <field name="groups" eval="[(4, ref('group_purcase_manager'))]"/>
            <field eval="1" name="perm_unlink"/>
            <field eval="1" name="perm_write"/>
            <field eval="1" name="perm_read"/>
            <field eval="1" name="perm_create"/>
        </record>

As you see in example i have created a rule to restrict other user to see each other recordand assign this rule to group purchase manager, you can restrict user access righs also like read, write, create, delete etc by this rule

Like in your example you make a rule to see company and his child reocrd all recordglobal means it rule apply to all with out assinging to any group

这篇关于Security.xml中的OpenERP ir.rule记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 01:39