diff --git a/reset_user_access_right/README.rst b/reset_user_access_right/README.rst new file mode 100644 index 000000000..db24f1b75 --- /dev/null +++ b/reset_user_access_right/README.rst @@ -0,0 +1,49 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================== +Reset User Access Right +======================== + +This module adds a button on users form view to reset groups access right. + +Installation +============ + +To install this module, you need to: + + * Click on install button + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + +Contributors +------------ + +* Adrien Peiffer + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/reset_user_access_right/__init__.py b/reset_user_access_right/__init__.py new file mode 100644 index 000000000..a0fdc10fe --- /dev/null +++ b/reset_user_access_right/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/reset_user_access_right/__openerp__.py b/reset_user_access_right/__openerp__.py new file mode 100644 index 000000000..67e876c62 --- /dev/null +++ b/reset_user_access_right/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of reset_user_access_right, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# reset_user_access_right is free software: +# you can redistribute it and/or modify it under the terms of the GNU +# Affero General Public License as published by the Free Software +# Foundation,either version 3 of the License, or (at your option) any +# later version. +# +# reset_user_access_right is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with reset_user_access_right. +# If not, see . +# +############################################################################## +{ + 'name': "Reset User Access Right", + 'summary': """Reset User Access Right""", + 'author': "ACSONE SA/NV,Odoo Community Association (OCA)", + 'website': "http://acsone.eu", + 'category': 'Uncategorized', + 'version': '8.0.1.0.0', + 'license': 'AGPL-3', + 'depends': [ + 'base', + ], + 'data': [ + 'views/res_users_view.xml', + ], +} diff --git a/reset_user_access_right/i18n/fr.po b/reset_user_access_right/i18n/fr.po new file mode 100644 index 000000000..31b844d95 --- /dev/null +++ b/reset_user_access_right/i18n/fr.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * reset_user_access_right +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-29 19:35+0000\n" +"PO-Revision-Date: 2015-09-29 19:35+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: reset_user_access_right +#: code:addons/reset_user_access_right/models/res_users.py:36 +#, python-format +msgid "It's not possible to reset access right for Admin" +msgstr "Il n'est pas possible de réinitialiser les droits d'accès de Admin" + +#. module: reset_user_access_right +#: view:res.users:reset_user_access_right.view_users_form +msgid "Reset Access Right" +msgstr "Réinitialiser les droits d'accès" + +#. module: reset_user_access_right +#: model:ir.model,name:reset_user_access_right.model_res_users +msgid "Users" +msgstr "Utilisateurs" + diff --git a/reset_user_access_right/i18n/reset_user_access_right.pot b/reset_user_access_right/i18n/reset_user_access_right.pot new file mode 100644 index 000000000..0a3e6c1a9 --- /dev/null +++ b/reset_user_access_right/i18n/reset_user_access_right.pot @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * reset_user_access_right +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-29 19:35+0000\n" +"PO-Revision-Date: 2015-09-29 19:35+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: reset_user_access_right +#: code:addons/reset_user_access_right/models/res_users.py:36 +#, python-format +msgid "It's not possible to reset access right for Admin" +msgstr "" + +#. module: reset_user_access_right +#: view:res.users:reset_user_access_right.view_users_form +msgid "Reset Access Right" +msgstr "" + +#. module: reset_user_access_right +#: model:ir.model,name:reset_user_access_right.model_res_users +msgid "Users" +msgstr "" + diff --git a/reset_user_access_right/models/__init__.py b/reset_user_access_right/models/__init__.py new file mode 100644 index 000000000..741ed460c --- /dev/null +++ b/reset_user_access_right/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import res_users diff --git a/reset_user_access_right/models/res_users.py b/reset_user_access_right/models/res_users.py new file mode 100644 index 000000000..0cbb1f5fb --- /dev/null +++ b/reset_user_access_right/models/res_users.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of reset_user_access_right, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# reset_user_access_right is free software: +# you can redistribute it and/or modify it under the terms of the GNU +# Affero General Public License as published by the Free Software +# Foundation,either version 3 of the License, or (at your option) any +# later version. +# +# reset_user_access_right is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with reset_user_access_right. +# If not, see . +# +############################################################################## + +from openerp import models, api, exceptions, _ +from openerp.tools import SUPERUSER_ID + + +class ResUsers(models.Model): + _inherit = 'res.users' + + @api.one + def reset_access_right(self): + if self.id == SUPERUSER_ID: + raise exceptions.Warning(_("It's not possible to reset " + "access right for Admin")) + default_groups_ids = self._get_group() + self.groups_id = [(6, 0, default_groups_ids)] diff --git a/reset_user_access_right/tests/__init__.py b/reset_user_access_right/tests/__init__.py new file mode 100644 index 000000000..fe3891401 --- /dev/null +++ b/reset_user_access_right/tests/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import test_reset_user_access_right diff --git a/reset_user_access_right/tests/test_reset_user_access_right.py b/reset_user_access_right/tests/test_reset_user_access_right.py new file mode 100644 index 000000000..f9b4246ea --- /dev/null +++ b/reset_user_access_right/tests/test_reset_user_access_right.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of reset_user_access_right, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# reset_user_access_right is free software: +# you can redistribute it and/or modify it under the terms of the GNU +# Affero General Public License as published by the Free Software +# Foundation,either version 3 of the License, or (at your option) any +# later version. +# +# reset_user_access_right is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with reset_user_access_right. +# If not, see . +# +############################################################################## + +from openerp.tests import common + + +class TestResetUserAccessRight(common.TransactionCase): + + def setUp(self): + super(TestResetUserAccessRight, self).setUp() + self.user_obj = self.env['res.users'] + + def test_reset_demo_user_access_right(self): + # I get the demo user + demo_user = self.env.ref('base.user_demo') + demo_user.groups_id = [(4, self.ref('base.group_no_one'))] + demo_user.reset_access_right() + default_groups_ids = self.user_obj._get_group() + # I check if access right on this user are reset + self.assertEquals(set(demo_user.groups_id.ids), + set(default_groups_ids)) diff --git a/reset_user_access_right/views/res_users_view.xml b/reset_user_access_right/views/res_users_view.xml new file mode 100644 index 000000000..83acfde7a --- /dev/null +++ b/reset_user_access_right/views/res_users_view.xml @@ -0,0 +1,15 @@ + + + + + res.users.form (reset_user_access_right) + res.users + + + +