Browse Source
Merge pull request #267 from acsone/8.0-add-reset-user-access-right-ape
Merge pull request #267 from acsone/8.0-add-reset-user-access-right-ape
[ADD] Add reset_user_access_right modulepull/316/head
Pedro M. Baeza
9 years ago
10 changed files with 256 additions and 0 deletions
-
45base_user_reset_access/README.rst
-
2base_user_reset_access/__init__.py
-
39base_user_reset_access/__openerp__.py
-
33base_user_reset_access/i18n/fr.po
-
33base_user_reset_access/i18n/reset_user_access_right.pot
-
2base_user_reset_access/models/__init__.py
-
40base_user_reset_access/models/res_users.py
-
2base_user_reset_access/tests/__init__.py
-
43base_user_reset_access/tests/test_base_user_reset_access.py
-
17base_user_reset_access/views/res_users_view.xml
@ -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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20base_user_reset_access%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Adrien Peiffer <adrien.peiffer@acsone.eu> |
||||
|
|
||||
|
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. |
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from . import models |
@ -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 (<http://acsone.eu>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
{ |
||||
|
'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', |
||||
|
], |
||||
|
} |
@ -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" |
||||
|
|
@ -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 "" |
||||
|
|
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from . import res_users |
@ -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 (<http://acsone.eu>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
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)] |
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from . import test_base_user_reset_access |
@ -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 (<http://acsone.eu>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
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)) |
@ -0,0 +1,17 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
<record id="view_users_form" model="ir.ui.view"> |
||||
|
<field name="name">res.users.form (base_user_reset_access)</field> |
||||
|
<field name="model">res.users</field> |
||||
|
<field name="inherit_id" ref="base.view_users_form" /> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//group[@string='Allowed Companies']" position="before"> |
||||
|
<button name="reset_access_right" string="Reset Access Right" type="object" |
||||
|
confirm="This will reset the user's access rights to the minimum configuration. Are you sure?"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</data> |
||||
|
</openerp> |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue