Inherit Group to ADD Remove group implied (inherited) Groups from existing Group in Odoo

We can add/remove implied  i.e. inherited groups in Odoo ERP System.

Add remove group from existing group in odoo.

Example:

In below example, I have one Group i.e. Employee / Officer with inherited User Type / Internal User.

Now we will remove Internal User from this group by using inherited code.

But before that we have to check for noupdate status. we can check noupdate status by click on,

 Button: Action-->Record Info-->XML ID



 Action-->Record Info-->XML ID


If noupdate boolean is check i.e. True. It means this will not update through the code. So we can set it False either manually or By Code itself then we can write code for add/remove new groups or existing groups.


Code:

1. Delete existing group (3-use for delete):

<record id="hr.group_hr_user" model="res.groups">
    <field name="implied_ids" eval="[(3, ref('base.group_user'))]" />
</record>

2. Add new group(4-use for append):

<record id="hr.group_hr_user" model="res.groups">
    <field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
</record>


If  you want to do noupdate=False and the process you group add/remove,


<data>
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value eval="[('module', '=', 'base'), ('name', '=', 'group_user')]"/>
</function>
<value eval="{'noupdate': False}"/>
</function>

<record id="hr.group_hr_user" model="res.groups">
<field name="implied_ids" eval="[(3, ref('base.group_user')),
(4, ref('base.group_user'))]" />
</record>

<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value eval="[('module', '=', 'base'), ('name', '=', 'group_user')]"/>
</function>
<value eval="{'noupdate': True}"/>
</function>
</data>


After this update your module and see for the same group. The given group get removed from inherit part.


Using same method you can do other changes also to the existing groups.

Comments

Popular posts from this blog

Company dependent field is not working in RECORD-RULE DOMAIN with multi-company configured system.

Open Many2one field in new Tab (Browser )from Tree View [odoo]