How to set default user group odoo 11

1.1k Views Asked by At

I have created a new group I want when I create a new user by default should take the group that I have created. my code

<record id="category_account_move_journal" model="ir.module.category">
     <field name="name">Journal Holder</field>
     <field name="description">Category for Journal</field>
     <field name="sequence">5 </field>
</record>
<record id="group_account_move_journal" model="res.groups">
     <field name="name">See his Journals</field>
     <field name="category_id" ref="category_account_move_journal"/>
     <field name="implied_ids" eval="[(4,ref('base.group_user'))]"/>
</record>
<record id="group_account_move_manager_journal" model="res.groups">
     <field name="name">See all Journals</field>
     <field name="category_id" ref="category_account_move_journal"/>
    <field name="implied_ids" eval="[(4,ref('group_account_move_journal'))]"/>
</record>

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

Odoo has a data record named "default_user" as a template for the newly created users.
An example of its use can be the _default_groups method in the res.user model:

def _default_groups(self):
    default_user = self.env.ref('base.default_user', raise_if_not_found=False)
    return (default_user or self.env['res.users']).sudo().groups_id

So you need to inherit this template and add the desired groups and the new users will have your group.

<record id="base.default_user" model="res.users">
    <field name="groups_id" eval="[(4,ref('your_group_external_id'))]"/>
</record>
<!-- your_group_external_id should be 'group_account_move_journal'
    or 'group_account_move_manager_journal' -->