diff --git a/base_user_reset_access/README.rst b/base_user_reset_access/README.rst new file mode 100644 index 000000000..2bea76793 --- /dev/null +++ b/base_user_reset_access/README.rst @@ -0,0 +1,45 @@ +.. 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 + +====================== +Base User Reset Access +====================== + +This module adds a button to reset the user's access rights to the minimum configuration. + +Installation +============ + +.. 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/base_user_reset_access/__init__.py b/base_user_reset_access/__init__.py new file mode 100644 index 000000000..a0fdc10fe --- /dev/null +++ b/base_user_reset_access/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/base_user_reset_access/__openerp__.py b/base_user_reset_access/__openerp__.py new file mode 100644 index 000000000..930f3eefa --- /dev/null +++ b/base_user_reset_access/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of base_user_reset_access, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# base_user_reset_access 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. +# +# base_user_reset_access 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 base_user_reset_access. +# If not, see . +# +############################################################################## +{ + 'name': "Base User Reset Access", + 'summary': """Reset User Access Right""", + 'author': "ACSONE SA/NV,Odoo Community Association (OCA)", + 'website': "http://acsone.eu", + 'category': 'Tools', + 'version': '8.0.1.0.0', + 'license': 'AGPL-3', + 'depends': [ + 'base', + ], + 'data': [ + 'views/res_users_view.xml', + ], +} diff --git a/base_user_reset_access/i18n/fr.po b/base_user_reset_access/i18n/fr.po new file mode 100644 index 000000000..c08f08c83 --- /dev/null +++ b/base_user_reset_access/i18n/fr.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_reset_access +# +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: base_user_reset_access +#: code:addons/base_user_reset_access/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: base_user_reset_access +#: view:res.users:base_user_reset_access.view_users_form +msgid "Reset Access Right" +msgstr "Réinitialiser les droits d'accès" + +#. module: base_user_reset_access +#: model:ir.model,name:base_user_reset_access.model_res_users +msgid "Users" +msgstr "Utilisateurs" + diff --git a/base_user_reset_access/i18n/reset_user_access_right.pot b/base_user_reset_access/i18n/reset_user_access_right.pot new file mode 100644 index 000000000..5fdb338a8 --- /dev/null +++ b/base_user_reset_access/i18n/reset_user_access_right.pot @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_reset_access +# +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: base_user_reset_access +#: code:addons/base_user_reset_access/models/res_users.py:36 +#, python-format +msgid "It's not possible to reset access right for Admin" +msgstr "" + +#. module: base_user_reset_access +#: view:res.users:base_user_reset_access.view_users_form +msgid "Reset Access Right" +msgstr "" + +#. module: base_user_reset_access +#: model:ir.model,name:base_user_reset_access.model_res_users +msgid "Users" +msgstr "" + diff --git a/base_user_reset_access/models/__init__.py b/base_user_reset_access/models/__init__.py new file mode 100644 index 000000000..741ed460c --- /dev/null +++ b/base_user_reset_access/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import res_users diff --git a/base_user_reset_access/models/res_users.py b/base_user_reset_access/models/res_users.py new file mode 100644 index 000000000..4474e1772 --- /dev/null +++ b/base_user_reset_access/models/res_users.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of base_user_reset_access, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# base_user_reset_access 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. +# +# base_user_reset_access 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 base_user_reset_access. +# If not, see . +# +############################################################################## + +from openerp import models, api, exceptions, _ +from openerp.tools import SUPERUSER_ID + + +class ResUsers(models.Model): + _inherit = 'res.users' + + @api.multi + def reset_access_right(self): + self.ensure_one() + 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/base_user_reset_access/tests/__init__.py b/base_user_reset_access/tests/__init__.py new file mode 100644 index 000000000..4a67f1230 --- /dev/null +++ b/base_user_reset_access/tests/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import test_base_user_reset_access diff --git a/base_user_reset_access/tests/test_base_user_reset_access.py b/base_user_reset_access/tests/test_base_user_reset_access.py new file mode 100644 index 000000000..ed4d4ee47 --- /dev/null +++ b/base_user_reset_access/tests/test_base_user_reset_access.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of base_user_reset_access, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# base_user_reset_access 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. +# +# base_user_reset_access 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 base_user_reset_access. +# 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/base_user_reset_access/views/res_users_view.xml b/base_user_reset_access/views/res_users_view.xml new file mode 100644 index 000000000..661495962 --- /dev/null +++ b/base_user_reset_access/views/res_users_view.xml @@ -0,0 +1,17 @@ + + + + + res.users.form (base_user_reset_access) + res.users + + + +