Browse Source

[REF] move raise on 'base.module.upgrade' model

pull/450/head
David Beal 8 years ago
parent
commit
3efac7fd33
  1. 2
      secure_uninstall/__openerp__.py
  2. 66
      secure_uninstall/i18n/fr.po
  3. 44
      secure_uninstall/models/module.py
  4. 25
      secure_uninstall/views/module_view.xml
  5. 32
      secure_uninstall/views/wizard_view.xml

2
secure_uninstall/__openerp__.py

@ -12,7 +12,7 @@
'depends': [
'base',
],
'data': ['views/wizard_view.xml'],
'data': ['views/module_view.xml'],
'website': 'http://www.akretion.com/',
'license': 'AGPL-3',
'installable': True,

66
secure_uninstall/i18n/fr.po

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-09 09:44+0000\n"
"PO-Revision-Date: 2016-06-09 11:52+0200\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"
@ -18,71 +18,31 @@ msgstr ""
"X-Generator: Poedit 1.8.7.1\n"
#. module: secure_uninstall
#: help:uninstall.check.wizard,password:0
#: help:base.module.upgrade,password:0
msgid "'admin_passwd' value from Odoo configuration file (aka 'Master Password')"
msgstr "la valeur 'admin_passwd' du fichier de configuration Odoo (aussi appelé 'Mot de passe Maître')"
#. module: secure_uninstall
#: view:uninstall.check.wizard:secure_uninstall.view_uninstall_wizard_form
msgid "Apply"
msgstr "Appliquer"
#. module: secure_uninstall
#: view:uninstall.check.wizard:secure_uninstall.view_uninstall_wizard_form
msgid "Cancel"
msgstr "Annuler"
#. module: secure_uninstall
#: view:uninstall.check.wizard:secure_uninstall.view_uninstall_wizard_form
msgid "Check"
msgstr "Vérifier"
#. module: secure_uninstall
#: field:uninstall.check.wizard,create_uid:0
msgid "Created by"
msgstr "Créé par"
#. module: secure_uninstall
#: field:uninstall.check.wizard,create_date:0
msgid "Created on"
msgstr "Créé le"
#. module: secure_uninstall
#: field:uninstall.check.wizard,id:0
msgid "ID"
msgstr "ID"
#. module: secure_uninstall
#: view:uninstall.check.wizard:secure_uninstall.view_uninstall_wizard_form
#: 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
#: field:uninstall.check.wizard,write_uid:0
msgid "Last Updated by"
msgstr "Mise à jour par"
#. module: secure_uninstall
#: field:uninstall.check.wizard,write_date:0
msgid "Last Updated on"
msgstr "Mis à jour"
#. module: secure_uninstall
#: model:ir.model,name:secure_uninstall.model_ir_module_module
msgid "Module"
msgstr "Module"
#. module: secure_uninstall
#: field:uninstall.check.wizard,password:0
msgid "Password"
msgstr "Mot de passe"
#: model:ir.model,name:secure_uninstall.model_base_module_upgrade
msgid "Module Upgrade"
msgstr "Mise à jour de module(s)"
#. module: secure_uninstall
#: view:uninstall.check.wizard:secure_uninstall.view_uninstall_wizard_form
msgid "Some columns can be dropped and there is no way to recover that except restoring a database backup"
msgstr "Certaines colonnes peuvent être supprimé et il n'y a aucun moyen de les retrouver excepté en restaurant une sauvegarde de la base de données"
#: field:base.module.upgrade,password:0
msgid "Password"
msgstr "Mot de passe"
#. module: secure_uninstall
#: view:uninstall.check.wizard:secure_uninstall.view_uninstall_wizard_form
msgid "Uninstall module process remove all data managed by the module."
msgstr "Le processus de désinstallation supprime toutes les données gérées par le module."
#: view:base.module.upgrade:secure_uninstall.view_base_module_upgrade
msgid "Secure Uninstall"
msgstr "Désintallation Securisé"

44
secure_uninstall/models/module.py

@ -2,44 +2,13 @@
# Copyright 2014 David BEAL @ Akretion <david.beal@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.osv import orm
from openerp import models, fields, api
from openerp.exceptions import Warning as UserError
from openerp.tools.config import config
class Module(orm.Model):
_inherit = 'ir.module.module'
def button_uninstall(self, cr, uid, ids, context=None):
# can't be convert in new api because use button_uninstall fct
# in _button_immediate_function() is buggy in new api.
# Next v10 will solve it.
if not context:
context = {}
if 'uninstall_authorized' in context:
ctx = context.copy()
del ctx['uninstall_authorized']
super(Module, self).button_uninstall(
cr, uid, ids, context=ctx)
return self._button_immediate_function(
cr, uid, ids, self.button_uninstall, context=ctx)
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(models.TransientModel):
_name = 'uninstall.check.wizard'
class BaseModuleUpgrade(models.TransientModel):
_inherit = 'base.module.upgrade'
password = fields.Char(
string='Password', required=True,
@ -47,9 +16,9 @@ class UninstallCheckWizard(models.TransientModel):
"(aka 'Master Password')")
@api.multi
def check_password(self):
for elm in self:
def upgrade_module(self):
config_passwd = config.get("admin_passwd")
for elm in self:
if not config_passwd:
raise UserError(
"Missing configuration key\n--------------------\n"
@ -66,7 +35,4 @@ class UninstallCheckWizard(models.TransientModel):
"\n\nResolution\n-------------\n"
"Please check your password and retry or cancel"
% elm.password)
module_id = self._context.get('module_id')
module = self.env['ir.module.module'].browse(module_id)
module.with_context(uninstall_authorized=True).button_uninstall()
return True
return super(BaseModuleUpgrade, self).upgrade_module()

25
secure_uninstall/views/module_view.xml

@ -0,0 +1,25 @@
<?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."
colspan="4" />
<group col="4">
<field name="password" password="True"/>
<span/>
</group>
</field>
</field>
</record>
</data>
</openerp>

32
secure_uninstall/views/wizard_view.xml

@ -1,32 +0,0 @@
<?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.<br/>
Some columns can be dropped and there is no way to recover that except restoring a database backup
</p>
<label string="If you want uninstall module, write required password."
colspan="4" />
<group col="4">
<field name="password" password="True"/>
<span/>
</group>
<footer>
<button name="check_password" string="Apply" type="object"
class="oe_highlight"/>
<button special="cancel" string="Cancel" class="oe_link"/>
</footer>
</form>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save