David Béal
10 years ago
committed by
David Beal
6 changed files with 163 additions and 0 deletions
-
5secure_uninstall/README.md
-
1secure_uninstall/__init__.py
-
50secure_uninstall/__openerp__.py
-
82secure_uninstall/module.py
-
BINsecure_uninstall/static/src/img/icon.png
-
25secure_uninstall/wizard_view.xml
@ -0,0 +1,5 @@ |
|||
Secure Uninstall |
|||
================ |
|||
|
|||
Ask admin password ('admin_passwd' key from config file) |
|||
before to proceed to module uninstallation |
@ -0,0 +1 @@ |
|||
from . import module |
@ -0,0 +1,50 @@ |
|||
# coding: utf-8 |
|||
############################################################################## |
|||
# |
|||
# Copyright (C) All Rights Reserved 2014 Akretion |
|||
# @author David BEAL <david.beal@akretion.com> |
|||
# |
|||
# This program 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. |
|||
# |
|||
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################### |
|||
|
|||
{ |
|||
'name': 'Secure Uninstall', |
|||
'version': '0.1', |
|||
'author': "Akretion,Odoo Community Association (OCA)", |
|||
'maintener': 'Akretion', |
|||
'category': 'Base', |
|||
'summary': "Ask password ot authorize uninstall", |
|||
'depends': [ |
|||
'base', |
|||
], |
|||
'description': """ |
|||
Secure Uninstall |
|||
================ |
|||
|
|||
Ask admin password ('admin_passwd' key from config file) |
|||
before to proceed to module uninstallation |
|||
|
|||
|
|||
Contributors |
|||
------------ |
|||
* David BEAL <david.beal@akretion.com> |
|||
|
|||
""", |
|||
'data': ['wizard_view.xml'], |
|||
'website': 'http://www.akretion.com/', |
|||
'license': 'AGPL-3', |
|||
'tests': [], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,82 @@ |
|||
# coding: utf-8 |
|||
############################################################################## |
|||
# |
|||
# Copyright (C) All Rights Reserved 2014 Akretion |
|||
# @author David BEAL <david.beal@akretion.com> |
|||
# |
|||
# This program 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. |
|||
# |
|||
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################### |
|||
|
|||
from openerp.osv import orm, fields |
|||
from openerp.tools.config import config |
|||
|
|||
|
|||
class Module(orm.Model): |
|||
_inherit = 'ir.module.module' |
|||
|
|||
def button_uninstall(self, cr, uid, ids, context=None): |
|||
if 'uninstall_authorized' in context: |
|||
del context['uninstall_authorized'] |
|||
res = super(Module, self).button_uninstall( |
|||
cr, uid, ids, context=context) |
|||
print res |
|||
return self._button_immediate_function( |
|||
cr, uid, ids, self.button_uninstall, context=context) |
|||
else: |
|||
_, view_id = self.pool['ir.model.data'].get_object_reference( |
|||
cr, uid, 'secure_uninstall', 'view_uninstall_wizard_form') |
|||
return { |
|||
'view_id': view_id, |
|||
'view_mode': 'form', |
|||
'res_model': 'uninstall.check.wizard', |
|||
'context': {'module_id': ids[0]}, |
|||
'name': "Uninstall Authorization", |
|||
'type': 'ir.actions.act_window', |
|||
'target': 'new', |
|||
} |
|||
|
|||
|
|||
class UninstallCheckWizard(orm.TransientModel): |
|||
_name = 'uninstall.check.wizard' |
|||
|
|||
_columns = { |
|||
'password': fields.char( |
|||
string='Password', |
|||
help="'admin_passwd' value from Odoo configuration file") |
|||
} |
|||
|
|||
def check_password(self, cr, uid, ids, context=None): |
|||
for elm in self.browse(cr, uid, ids, context=context): |
|||
|
|||
config_passwd = config.get("admin_passwd") |
|||
if not config_passwd: |
|||
raise orm.except_orm( |
|||
'Missing configuration key', |
|||
"'admin_passwd' configuration key is not set in " |
|||
"your Odoo server configuration file: " |
|||
"please set it a value") |
|||
if elm.password != config_passwd: |
|||
raise orm.except_orm( |
|||
"Password Error", |
|||
"Issue\n_____\nProvided password '%s' doesn't match with " |
|||
"'admin_passwd' comes from your " |
|||
"Odoo server configuration file." |
|||
"\n\nResolution\n__________\n" |
|||
"Please check your password and retry or cancel" |
|||
% elm.password) |
|||
context['uninstall_authorized'] = True |
|||
module_id = context.get('module_id') |
|||
self.pool['ir.module.module'].button_uninstall( |
|||
cr, uid, [module_id], context=context) |
After Width: 171 | Height: 156 | Size: 21 KiB |
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<openerp> |
|||
<data> |
|||
|
|||
|
|||
<record id="view_uninstall_wizard_form" model="ir.ui.view"> |
|||
<field name="model">uninstall.check.wizard</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Check" version="7.0"> |
|||
<p class="oe_inline oe_grey"> |
|||
Uninstall module process remove all data managed by the module |
|||
</p> |
|||
<label string="If you want uninstall module, write required password" |
|||
colspan="4" /> |
|||
<field name="password"/> |
|||
<button icon="gtk-ok" name="check_password" string="Apply" type="object"/> |
|||
<button icon="gtk-cancel" special="cancel" string="Cancel"/> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue