Browse Source

Merge pull request #599 from akretion/fix-secure-uninstall

FIX secure_uninstall
pull/630/head
Sylvain LE GAL 8 years ago
committed by GitHub
parent
commit
f5a671a6b6
  1. 5
      secure_uninstall/README.rst
  2. 14
      secure_uninstall/models/module.py
  3. 2
      secure_uninstall/views/module_view.xml

5
secure_uninstall/README.rst

@ -40,6 +40,11 @@ Usage
:target: https://runbot.odoo-community.org/runbot/149/server-tools
Known issues / Roadmap
======================
* This module can be uninstall properly: needs to be fixed soon
* This module allowed us to discover this bug in core Odoo https://github.com/odoo/odoo/issues/14452: hoping it will fixed
Bug Tracker
===========

14
secure_uninstall/models/module.py

@ -24,6 +24,7 @@ class BaseModuleUpgrade(models.TransientModel):
def upgrade_module(self):
for elm in self:
if not config.get("secure_uninstall"):
self.rollback_state_modules()
raise UserError(_(
"Missing configuration key\n--------------------\n"
"'secure_uninstall' configuration key "
@ -31,6 +32,7 @@ class BaseModuleUpgrade(models.TransientModel):
"your Odoo server configuration file: "
"please set it a value"))
if elm.uninstall_password not in _get_authorized_password():
self.rollback_state_modules()
raise UserError(_(
"Password Error\n--------------------\n"
"Provided password '%s' doesn't match with "
@ -42,3 +44,15 @@ class BaseModuleUpgrade(models.TransientModel):
# keep this password in db is insecure, then we remove it
elm.uninstall_password = False
return super(BaseModuleUpgrade, self).upgrade_module()
def rollback_state_modules(self):
modules = self.env['ir.module.module'].browse(
self._context.get('active_ids'))
if modules:
module_ids = modules.downstream_dependencies(
exclude_states=['uninstalled', 'uninstallable'])
module_ids = module_ids + list(modules._ids)
self.env['ir.module.module'].browse(
module_ids).button_uninstall_cancel()
self._cr.commit()
return True

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="uninstall_password" password="True" attrs="{'required': 1}"
<field name="uninstall_password" password="True"
placeholder="key_provided_by_administrator"/>
<span/>
</group>

Loading…
Cancel
Save