This question has been flagged

Hello,

Im trying to create the Access right to custom model using the dropdown style via group definition.

I define two groups with custom access right in ir.model.access.csv :

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

access_model_a,access_model_a,model_a,group_manager,1,1,1,1

access_model_b,access_model_b,model_dieu_b,group_manager,1,1,1,1

access_model_c,access_model_c,model_c,group_manager,1,1,1,1

remote_model_a,Remote model a,model_a,group_user,1,0,0,0

remote_model_b,Remote model b,model_b,group_user,1,0,0,0

remote_model_c,Remote model c,model_c,group_user,1,0,0,0


My security.xml in the Security folder like this:

<odoo>   

    <record model="ir.module.category" id="model_category">

        <field name="name">Test Security</field>

        <field name="description">Test access right to custom model</field>

        <field name="sequence">81</field>

    </record>

    

    <record id="group_manager" model="res.groups">

        <field name="name">Manager</field>

        <field name="category_id" ref="model_category"/>

    </record>   

    <record id="group_user" model="res.groups">

        <field name="name">User</field>

        <field name="category_id" ref="model_category"/>

        <field name="implied_ids" eval="[(4, ref('group_manager'))]"/>

    </record>    

</odoo>


So, for using the dropdown style of access right to the custom model, need to add the field:

    <field name="implied_ids" eval="[(4, ref('group_manager'))]"/>

When adding the user name to 'group_user' via choosing 'User' in the dropdown style. It will add the user name in group_user.

But it also adds the user name to 'group_manager' too and applies the access right rule of group_manager for the user, instead of using the access right rule of group_user. 

That is my issue. So how to solve it by using the dropdown style?


Please help!

Thank you!

Avatar
Discard
Best Answer

Your code is almost correct except the implied of the group.

The manager group should imply the user group as follow:

<record id="group_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="model_category"/>
</record>

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

Implied means, inheriting one group into another group which adds all the security rights/rules into another group.

Avatar
Discard
Author

Hi Sudhir,

Thank you for your support. I'd changed via your code. After changed to like that, the issue is when selecting 'User' in the dropdown access right style. It will auto turn to 'Manager' !

Please open your Manager group from the settings, click on "Inherited" and remove the User group.

Then upgrade your module again and your issue will be resolved.

Author

After clicking on the tab "Inherited" and remove the model_name / User Manager group. I selected again and still have the same issue after upgrade my module. It also adds model_name /User in Manager group again too.

Author

Yes, I got it. Many thanks, Sudhir !