[REF] Server Environment: restrict access to server config to allowed users

New security group restricting access to server config
Admin is part of the group by default
This commit is contained in:
Thomas Binsfeld 2018-10-08 11:45:13 +02:00 committed by Yannick Vaucher
parent b6ae38f48e
commit 041db8b97f
3 changed files with 16 additions and 0 deletions

View File

@ -31,6 +31,7 @@
"license": "GPL-3 or any later version", "license": "GPL-3 or any later version",
"category": "Tools", "category": "Tools",
"data": [ "data": [
'security/res_groups.xml',
'serv_config.xml', 'serv_config.xml',
], ],
'installable': True, 'installable': True,

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<odoo>
<record model="res.groups" id="has_server_configuration_access">
<field name="name">View Server Environment Configuration</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</odoo>

View File

@ -286,6 +286,11 @@ class ServerConfiguration(models.TransientModel):
@api.model @api.model
def default_get(self, fields_list): def default_get(self, fields_list):
res = {} res = {}
current_user = self.pool['res.users'].browse(
cr, uid, uid, context=context)
if not current_user.has_group(
'server_environment.has_server_configuration_access'):
return res
for key in self._conf_defaults: for key in self._conf_defaults:
if 'passw' in key and not self.show_passwords: if 'passw' in key and not self.show_passwords:
res[key] = '**********' res[key] = '**********'