<h2 class="oe_fade"><field name="summary"/></h2>
<button name="button_immediate_install" states="uninstalled" string="Install" type="object" class="oe_highlight"/>
<button name="button_immediate_upgrade" states="installed" string="Upgrade" type="object" class="oe_highlight"/>
- <button name="button_immediate_uninstall" states="installed" string="Uninstall" type="object"
- confirm="Do you confirm the uninstallation of this module? This will permanently erase all data currently stored by the module!"/>
+ <button name="button_uninstall" states="installed" string="Uninstall" type="object"/>
<button name="button_uninstall_cancel" states="to remove" string="Cancel Uninstall" type="object"/>
<button name="button_upgrade_cancel" states="to upgrade" string="Cancel Upgrade" type="object"/>
<button name="button_install_cancel" states="to install" string="Cancel Install" type="object"/>
res = mod_obj.read(cr, uid, ids, ['name','state'], context)
return {'module_info': '\n'.join(map(lambda x: x['name']+' : '+x['state'], res))}
+ def upgrade_module_cancel(self, cr, uid, ids, context=None):
+ mod_obj = self.pool.get('ir.module.module')
+ to_installed_ids = mod_obj.search(cr, uid, [
+ ('state', 'in', ['to upgrade', 'to remove'])])
+ if to_installed_ids:
+ mod_obj.write(cr, uid, to_installed_ids, {'state': 'installed'}, context=context)
+
+ to_uninstalled_ids = mod_obj.search(cr, uid, [
+ ('state', '=', 'to install')])
+ if to_uninstalled_ids:
+ mod_obj.write(cr, uid, to_uninstalled_ids, {'state': 'uninstalled'}, context=context)
+
+ return {'type': 'ir.actions.act_window_close'}
+
def upgrade_module(self, cr, uid, ids, context=None):
ir_module = self.pool.get('ir.module.module')
<field name="model">base.module.upgrade</field>
<field name="arch" type="xml">
<form string="System Update" version="7.0">
- <div><label string="Your system will be updated."/></div>
- <div><label string="Note that this operation might take a few minutes."/></div>
- <separator string="Modules to Update"/>
+ <p>This module will trigger the uninstallation of below modules.</p>
+ <p><strong>This operation will permanently erase all data currently stored by the modules!</strong></p>
+ <p>If you wish to cancel the process, press the cancel button below</p>
+ <separator string="Impacted Modules"/>
<field name="module_info"/>
<footer>
<button name="upgrade_module" string="Update" type="object" class="oe_highlight"/>
or
- <button string="Cancel" class="oe_link" special="cancel"/>
+ <button string="Cancel" class="oe_link" name="upgrade_module_cancel" type="object"/>
</footer>
</form>
</field>
from openerp.osv import osv, fields
from openerp.tools import ustr
from openerp.tools.translate import _
+from lxml import etree
_logger = logging.getLogger(__name__)
def copy(self, cr, uid, id, values, context=None):
raise osv.except_osv(_("Cannot duplicate configuration!"), "")
+ def fields_view_get(self, cr, user, view_id=None, view_type='form',
+ context=None, toolbar=False, submenu=False):
+ ret_val = super(res_config_settings, self).fields_view_get(
+ cr, user, view_id=view_id, view_type=view_type, context=context,
+ toolbar=toolbar, submenu=submenu)
+
+ doc = etree.XML(ret_val['arch'])
+
+ for field in ret_val['fields']:
+ if not field.startswith("module_"):
+ continue
+ for node in doc.xpath("//field[@name='%s']" % field):
+ if 'on_change' not in node.attrib:
+ node.set("on_change",
+ "onchange_module(%s, '%s')" % (field, field))
+
+ ret_val['arch'] = etree.tostring(doc)
+ return ret_val
+
+ def onchange_module(self, cr, uid, ids, field_value, module_name, context={}):
+ module_pool = self.pool.get('ir.module.module')
+ module_ids = module_pool.search(
+ cr, uid, [('name', '=', module_name.replace("module_", '')),
+ ('state','in', ['to install', 'installed', 'to upgrade'])],
+ context=context)
+
+ if module_ids and not field_value:
+ dep_ids = module_pool.downstream_dependencies(cr, uid, module_ids, context=context)
+ dep_name = [x.shortdesc for x in module_pool.browse(
+ cr, uid, dep_ids + module_ids, context=context)]
+ message = '\n'.join(dep_name)
+ return {'warning': {'title': _('Warning!'),
+ 'message':
+ _('Disabling this option will also uninstall the following modules \n%s' % message)
+ }}
+ return {}
+
def _get_classified_fields(self, cr, uid, context=None):
""" return a dictionary with the fields classified by category::