OpenERP ir.rule records in security.xml

拥有回忆 提交于 2020-01-13 05:43:06

问题


    <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 files which 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.?


回答1:


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 record and 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 record global means it rule apply to all with out assinging to any group



来源:https://stackoverflow.com/questions/16234383/openerp-ir-rule-records-in-security-xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!