Browse Source

Merge pull request #450 from akretion/8-secure-uninstall

[PORT] module secure_uninstall to v8
pull/539/head
beau sebastien 8 years ago
committed by GitHub
parent
commit
9301068b62
  1. 75
      secure_uninstall/README.rst
  2. 1
      secure_uninstall/__init__.py
  3. 19
      secure_uninstall/__openerp__.py
  4. 48
      secure_uninstall/i18n/fr.po
  5. 1
      secure_uninstall/models/__init__.py
  6. 44
      secure_uninstall/models/module.py
  7. BIN
      secure_uninstall/static/description/icon.png
  8. BIN
      secure_uninstall/static/description/img1.png
  9. 1
      secure_uninstall/tests/__init__.py
  10. 18
      secure_uninstall/tests/test_uninstall.py
  11. 26
      secure_uninstall/views/module_view.xml

75
secure_uninstall/README.rst

@ -0,0 +1,75 @@
.. 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
================
Secure Uninstall
================
Odoo erase all data managed by uninstalled modules.
To prevent catastrophe this module ask password
before proceeding to module uninstallation.
.. figure:: secure_uninstall/static/description/img1.png
:alt: Uninstall authorized
:width: 70%
|
Configuration
=============
Set 'secure_uninstall' key in Odoo configuration file.
Usage
=====
#. Go to Settings > Local modules.
#. Click on one module.
#. Click on Uninstall button.
#. You will need to enter a specific password before proceeding (password provided by administrator).
.. 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/server-tools
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.
Credits
=======
Contributors
------------
* David Béal <david.beal@akretion.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://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 https://odoo-community.org.

1
secure_uninstall/__init__.py

@ -0,0 +1 @@
from . import models

19
secure_uninstall/__openerp__.py

@ -0,0 +1,19 @@
# coding: utf-8
# Copyright 2014 David BEAL @ Akretion <david.beal@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Secure Uninstall',
'summary': "Ask password to authorize uninstall",
'version': '8.0.1.0.0',
'author': "Akretion,Odoo Community Association (OCA)",
'category': 'Base',
'depends': [
'base',
],
'data': ['views/module_view.xml'],
'website': 'http://www.akretion.com/',
'license': 'AGPL-3',
'installable': True,
}

48
secure_uninstall/i18n/fr.po

@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * secure_uninstall
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-16 15:26+0000\n"
"PO-Revision-Date: 2016-08-16 17:29+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: fr\n"
"X-Generator: Poedit 1.8.7.1\n"
#. module: secure_uninstall
#: help:base.module.upgrade,password:0
msgid "'secure_uninstall' value from Odoo configuration file (aka 'Master Password')"
msgstr "la valeur 'secure_uninstall' du fichier de configuration Odoo (aussi appelé 'Mot de passe Maître')"
#. module: secure_uninstall
#: view:base.module.upgrade:secure_uninstall.view_base_module_upgrade
msgid "If you want uninstall module, write required password."
msgstr "Si vous voulez désinstaller un module, écrivez le mot de passe requis."
#. module: secure_uninstall
#: model:ir.model,name:secure_uninstall.model_ir_module_module
msgid "Module"
msgstr "Module"
#. module: secure_uninstall
#: model:ir.model,name:secure_uninstall.model_base_module_upgrade
msgid "Module Upgrade"
msgstr "Mise à jour de module(s)"
#. module: secure_uninstall
#: field:base.module.upgrade,password:0
msgid "Password"
msgstr "Mot de passe"
#. module: secure_uninstall
#: view:base.module.upgrade:secure_uninstall.view_base_module_upgrade
msgid "Secure Uninstall"
msgstr "Désintallation Securisée"

1
secure_uninstall/models/__init__.py

@ -0,0 +1 @@
from . import module

44
secure_uninstall/models/module.py

@ -0,0 +1,44 @@
# coding: utf-8
# Copyright 2014 David BEAL @ Akretion <david.beal@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api
from openerp.exceptions import Warning as UserError
from openerp.tools.config import config
def _get_authorized_password():
""" You can define your own authorized keys
"""
return [config.get("secure_uninstall"), config.get("admin_passwd")]
class BaseModuleUpgrade(models.TransientModel):
_inherit = 'base.module.upgrade'
uninstall_password = fields.Char(
string='Password',
help="'secure_uninstall' value from Odoo configuration file ")
@api.multi
def upgrade_module(self):
for elm in self:
if not config.get("secure_uninstall"):
raise UserError(
"Missing configuration key\n--------------------\n"
"'secure_uninstall' configuration key "
"is not set in \n"
"your Odoo server configuration file: "
"please set it a value")
if elm.uninstall_password not in _get_authorized_password():
raise UserError(
"Password Error\n--------------------\n"
"Provided password '%s' doesn't match with "
"'Master Password'\n('secure_uninstall' key) found in "
"the Odoo server configuration file ."
"\n\nResolution\n-------------\n"
"Please check your password and retry or cancel"
% elm.uninstall_password)
# keep this password in db is insecure, then we remove it
elm.uninstall_password = False
return super(BaseModuleUpgrade, self).upgrade_module()

BIN
secure_uninstall/static/description/icon.png

After

Width: 171  |  Height: 156  |  Size: 21 KiB

BIN
secure_uninstall/static/description/img1.png

After

Width: 819  |  Height: 501  |  Size: 58 KiB

1
secure_uninstall/tests/__init__.py

@ -0,0 +1 @@
from . import test_uninstall

18
secure_uninstall/tests/test_uninstall.py

@ -0,0 +1,18 @@
# coding: utf-8
# © 2016 David BEAL @ Akretion <david.beal@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import TransactionCase
class TestSecureUninstall(TransactionCase):
def test_secure_uninstall_without_key(self):
vals = {'uninstall_password': 'toto'}
bmu = self.env['base.module.upgrade'].create(vals)
try:
bmu.upgrade_module()
except Exception as e:
messages = ('Missing configuration key',
'Password Error\n----------')
self.assertIn(e.message[:25], messages)

26
secure_uninstall/views/module_view.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_base_module_upgrade" model="ir.ui.view">
<field name="model">base.module.upgrade</field>
<field name="inherit_id" ref="base.view_base_module_upgrade"/>
<field name="arch" type="xml">
<field name="module_info" position="after">
<separator string="Secure Uninstall"/>
<label string="If you want uninstall module, write required password ('secure_uninstall' key in ERP config file)."
colspan="4" />
<group col="4">
<field name="uninstall_password" password="True" attrs="{'required': 1}"
placeholder="key_provided_by_administrator"/>
<span/>
</group>
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save