-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure user privileges #11
Comments
Hi, It is possible of course. First thing to know is that any database record can be created in two way: manually by a user (through the interface or OERPLib), or automatically when installing a module. Almost all basic data you will find after the creation of a new database have been created automatically with the installation of a module. The important point here is the So, you have to know the external ID of this Technical Features group, and from there you will be able to set it on any user accounts you want with OERPLib:
Now you have the external ID, you can get the corresponding database ID on the fly, and use it the way you want: >>> oerp.get('ir.model.data').get_object_reference('base', 'group_no_one')
['res.groups', 8]
>>> data_model = oerp.get('ir.model.data')
>>> user_model = oerp.get('res.users')
>>> res_model, res_id = data_model.get_object_reference('base', 'group_no_one')
>>> user = user_model.browse(1) # User account to update
>>> user.groups_id += res_id # We add the 'Technical Features' group to the user
>>> oerp.write_record(user) # Save modifications The Regards, |
Hi, Sébastien. As always, I thank you for your time and good will. Before opening this issue I had researched the use of the Developer Mode, as you've suggested before and I found it very interesting. Without to have a theoretical basis as theoretical as you gave me (thanks for that!), I had observed that in Users -> Administrator, with Developer Mode enabled, when positioned the mouse over Technical Features, I found the following:
Then, making a dump of the database I found where this value was, although mine was somewhat rustic. I was losing the theoretical base.
I was testing the code in your example (thanks for the comments), but I get the following error res_model, res_id = data_model.get_object_reference('base', 'group_no_one') The exception produced is the following:
./create_odoo_databaseV3.py opcionlibre 0 es_AR 95678Traceback (most recent call last):
2014-12-29 21:53:24,421 24017 ERROR opcionlibre openerp.http: get_object_reference() got an unexpected keyword argument 'context'
|
Indeed, most RPC methods accept a >>> oerp.config['auto_context'] = False
>>> res_model, res_id = data_model.get_object_reference('base', 'group_no_one')
>>> oerp.config['auto_context'] = True See: http://pythonhosted.org//OERPLib/faq.html#some-osv-methods-does-not-accept-the-context-parameter Regards, |
Hi, Sébastien. Great! Thanks for the reference on the documentation! Regarding the second point that I had commented in the original message:
In Lauchpad I found the following code that you had commented to create a user: oerp.login('admin', 'password', 'opcionlibre')
user_obj = oerp.get('res.users')
user_obj.create({'name':'Wolfgang Boehmer', 'login':'wolfgangb', 'password':'password2'}) I guess the goal would be to have the technical features enabled but without the Modules menu (correct me if I'm wrong, please). Although I'm still new at in this matter of privilege settings and I am investigating how do it. Any help is welcome. I was also thinking if it is possible that the "subadmin" user has permissions to install only a subset of the available modules, although this is something (let's say) more ambitious. Best regards, |
Sorry for the delay, time is a scarce resource ;)
Merge all of this, and you will be able to do what you want. |
Hi, Sébastien/etsinko.
After being able to automate the creation of a database with the corresponding administrator, I wonder if it is possible to configure access to "technical features" also automatically after creation (I think this is basic to an administrator user), using oerplib. I think the res_groups table is used for set the privileges, although I didn't see the relation with res_users.
I was also investigating how to create an administrator user with restricted permissions (eg he/her can not install modules). At first I tried it from the web interface for viewing the mechanism to follow and try to replicate it with oerplib, but I could not get it yet. The official documentation on the Odoo official site also was not very useful for me. This is also achieved by configuring the user group?
Thanks again for your time.
Kind regards,
Daniel
The text was updated successfully, but these errors were encountered: