Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to enable a security group for all users?

By
Atchuthan - Technical Consultant, Sodexis Inc
on 8/19/14, 2:24 AM 3,566 views

I created a new group via XML for access rights management

        <record model="res.groups" id="group_no_open_procurement">
            <field name="name">Only Tree view for procurement</field>
        </record>

I need to enable this group for all the users by code itself and not manually changing @ User window.  How should I proceed?

 

This question has been included in the official documentation.
4

René Schuster

--René Schuster--
1560
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 8/19/14, 4:24 AM

Add your new group to the inherited_ids of base.group_user.

Either in the web client, or in via your security xml file:

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

This might be easier and adds your group to all existing users aswell (not just new ones), but I think prakashs suggestion is the cleaner way.

 

Regards.

This question has been included in the official documentation.
2

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 8/19/14, 4:12 AM

In the Users Default Group "Employee" (ID of the group group_user) and "Contact Creatation" (ID of the group group_partner_manager) Enable to creating new user.

Code: addons\base\res\res_users.py

    def _get_group(self,cr, uid, context=None):
        dataobj = self.pool.get('ir.model.data')
        result = []
        try:
            dummy,group_id = dataobj.get_object_reference(cr, SUPERUSER_ID, 'base', 'group_user')
            result.append(group_id)
            dummy,group_id = dataobj.get_object_reference(cr, SUPERUSER_ID, 'base', 'group_partner_manager')
            result.append(group_id)

          dummy,group_id = dataobj.get_object_reference(cr, SUPERUSER_ID, 'module_name', 'group_no_open_procurement')
            result.append(group_id)

        except ValueError:
            # If these groups does not exists anymore
            pass
        return result

    _defaults = {
        'groups_id': _get_group,
    }

In the custom module inherit the above default method and add highligted code creating new user it enable group_no_open_procurement group.

EDIT:-

The above code enable group for creating New user. Already created user using the code update the res_groups_users_rel many2many relation table using code or xml file.

This question has been included in the official documentation.
0
Deviprasad V
On 8/19/14, 5:28 AM

The correct method is add to your scurity xml file. Inside the users tag

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/19/14, 2:24 AM
Seen: 3566 times
Last updated: 2/15/16, 7:02 AM