我如何控制用户的访问和视图?在 Odoo

How can i controll the access and views of user? in Odoo

大家晚上好...我创建了一个模块,其中有两种用户组。1 是客户,2 是管理员。它只有一个顶级菜单。我想在客户 logins.So 安全 erp 的解决方案是什么?

时隐藏一些左侧菜单项

提前致谢

在模块的 SECURITY 文件夹中创建一个 XML 文件。

<record model="ir.rule" id="ir_values_my_costume_rule">
    <field name="name">My Rule Name</field>
    <field name="model_id" ref="model_your_model_name"/>
    <field name="domain_force">[('field','operator','value'),('user_id','=',user.id)]</field>
    <field name="perm_read" eval="True"/>
    <field name="perm_write" eval="True"/>
    <field name="perm_unlink" eval="True"/>
    <field name="perm_create" eval="True"/>
</record>

您必须在模型名称前传递 model_,如下所示:model_sale_order 或 model_project_task.

eval 中,您可以根据需要传递 TrueFalse

然后你需要像这样使用 'groups' 属性:

<menuitem action="ACTION_ID" id="NEW_MENU_ID" 
       parent="PARENT_MENU_ID" groups="GROUP_XML_ID"/>

在 xml 文件中进行此更改后,

in your __openerp__.py file ---> in your data tag make an entry for this file.

For example, data:[security/your_module_security.xml]

restart the Openerp server

Upgrade your module and check it.