Browse Source

[ADD] Add reset_user_access_right module

pull/267/head
Adrien Peiffer (ACSONE) 9 years ago
parent
commit
763d450360
  1. 49
      reset_user_access_right/README.rst
  2. 2
      reset_user_access_right/__init__.py
  3. 39
      reset_user_access_right/__openerp__.py
  4. 33
      reset_user_access_right/i18n/fr.po
  5. 33
      reset_user_access_right/i18n/reset_user_access_right.pot
  6. 2
      reset_user_access_right/models/__init__.py
  7. 39
      reset_user_access_right/models/res_users.py
  8. 2
      reset_user_access_right/tests/__init__.py
  9. 43
      reset_user_access_right/tests/test_reset_user_access_right.py
  10. 15
      reset_user_access_right/views/res_users_view.xml

49
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 <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:%20reset_user_access_right%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.

2
reset_user_access_right/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

39
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 (<http://acsone.eu>)
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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',
],
}

33
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"

33
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 ""

2
reset_user_access_right/models/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import res_users

39
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 (<http://acsone.eu>)
#
# 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 <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.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)]

2
reset_user_access_right/tests/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import test_reset_user_access_right

43
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 (<http://acsone.eu>)
#
# 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 <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))

15
reset_user_access_right/views/res_users_view.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_users_form" model="ir.ui.view">
<field name="name">res.users.form (reset_user_access_right)</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" />
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save