简体   繁体   English

Odoo 10:安全组不适用于“编辑/创建”按钮

[英]Odoo 10 : Security groups are not working on edit/create button

Aim : to make appear the Edit/create button only for user group : Manager 目的 :仅针对用户组: 管理员显示“编辑/创建”按钮

Module name : Simcard 模块名称 :Simcard

Model Name : simcard_simcard 型号名称 :simcard_simcard

my csv file : 我的csv文件:

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
demo_admin, Model admin access,model_simcard_simcard,simcard.group_manager,1,1,1,1
demo_user, Model user access,model_simcard_simcard,simcard.group_user,0,0,0,0

My user_groups.xml : 我的user_groups.xml:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
  <data>
    <record model="ir.module.category" id="module_management">
      <field name="name">Simcard</field>
      <field name="description">User access level for this module</field>
      <field name="sequence">3</field>
    </record>

   <record id="group_user" model="res.groups">
     <field name="name">User</field>
     <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
     <field name="users" eval="[(4, ref('base.user_root'))]"/>
     <field name="category_id" ref="simcard.module_management"/>
    </record>

    <record id="group_manager" model="res.groups">
      <field name="name">Manager</field>
      <field name="implied_ids" eval="[(4, ref('simcard.group_user'))]"/>
      <field name="category_id" ref="simcard.module_management"/>
    </record>
</data>
</odoo>

My views.xml : 我的views.xml:

<record id="remove_edit" model="ir.ui.view">
    <field name="name">remove.edit</field>
    <field name="model">simcard.simcard</field>
    <field name="inherit_id" ref="simcard.view_sim_form"/>
    <!-- <field name="groups_id" eval="[(4, [ref('simcard.group_manager')])]"/> -->
    <field name="arch" type="xml">
        <xpath expr="//form" position="attributes">
            <attribute name="edit">true</attribute>
            <attribute name="groups">simcard.group_manager</attribute>

        </xpath>
    </field>
    </record>

This Edit button still appears for normal users. 对于普通用户,此编辑按钮仍会出现。

In the csv, in model_id:id column, add your module_name. 在csv的model_id:id列中,添加您的module_name。 before: 之前:

simcard.model_simcard_simcard

You better solve this by using 2 records of ir.rule , one global(will apply for all the users and groups, without specifying a group) to restrict the create and write actions with a domain_force like: 您最好使用ir.rule 2条记录来解决此ir.rule ,其中一条全局(将适用于所有用户和组,而不指定组)限制了使用domain_force的创建和写入操作,例如:

[(1,'=',1)]

And another record associated with the group simcard.group_manager to allow the create and edit actions with the same domain_force: 另一个与组simcard.group_manager关联的记录,以允许使用相同的domain_force创建和编辑操作:

[(1,'=',1)]

And remove all of those view customizations 并删除所有这些视图自定义项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM