Browse Source

[IMP] make key to authorise uninstall overridable

pull/450/head
David Beal 8 years ago
parent
commit
33ac3008a3
  1. 2
      secure_uninstall/README.rst
  2. 2
      secure_uninstall/i18n/fr.po
  3. 21
      secure_uninstall/models/module.py
  4. 2
      secure_uninstall/views/module_view.xml

2
secure_uninstall/README.rst

@ -32,7 +32,7 @@ Usage
#. Go to Settings > Local modules.
#. Click on one module.
#. Click on Uninstall button.
#. You will need to enter 'secure_uninstall' value provided by your administrator before proceeding.
#. 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

2
secure_uninstall/i18n/fr.po

@ -45,4 +45,4 @@ msgstr "Mot de passe"
#. module: secure_uninstall
#: view:base.module.upgrade:secure_uninstall.view_base_module_upgrade
msgid "Secure Uninstall"
msgstr "Désintallation Securisé"
msgstr "Désintallation Securisée"

21
secure_uninstall/models/module.py

@ -7,33 +7,38 @@ from openerp.exceptions import Warning as UserError
from openerp.tools.config import config
def _get_authorized_password(self):
""" You can define your own authorized keys
"""
return [config.get("secure_uninstall")]
class BaseModuleUpgrade(models.TransientModel):
_inherit = 'base.module.upgrade'
password = fields.Char(
uninstall_password = fields.Char(
string='Password',
help="'secure_uninstall' value from Odoo configuration file ")
@api.multi
def upgrade_module(self):
config_passwd = config.get("secure_uninstall")
for elm in self:
if not config_passwd:
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.password != config_passwd:
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 ."
"'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.password)
% elm.uninstall_password)
# keep this password in db is insecure, then we remove it
elm.password = False
elm.uninstall_password = False
return super(BaseModuleUpgrade, self).upgrade_module()

2
secure_uninstall/views/module_view.xml

@ -13,7 +13,7 @@
<label string="If you want uninstall module, write required password ('secure_uninstall' key in ERP config file)."
colspan="4" />
<group col="4">
<field name="password" password="True" attrs="{'required': 1}"
<field name="uninstall_password" password="True" attrs="{'required': 1}"
placeholder="key_provided_by_administrator"/>
<span/>
</group>

Loading…
Cancel
Save