[FIX] module: Use the button_immediate_XYZ of the upgrade and uninstall buttons in the form view
bzr revid: stw@openerp.com-20120808104354-xzwue50utz50wspu
This commit is contained in:
parent
67518796c6
commit
2dce7f3ef8
|
@ -355,22 +355,7 @@ class module(osv.osv):
|
|||
:returns: next res.config item to execute
|
||||
:rtype: dict[str, object]
|
||||
"""
|
||||
self.button_install(cr, uid, ids, context=context)
|
||||
cr.commit()
|
||||
_, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
||||
|
||||
config = pool.get('res.config').next(cr, uid, [], context=context) or {}
|
||||
if config.get('type') not in ('ir.actions.reload', 'ir.actions.act_window_close'):
|
||||
return config
|
||||
|
||||
# reload the client; open the first available root menu
|
||||
menu_obj = self.pool.get('ir.ui.menu')
|
||||
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'reload',
|
||||
'params': {'menu_id': menu_ids and menu_ids[0] or False},
|
||||
}
|
||||
return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
|
||||
|
||||
def button_install_cancel(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})
|
||||
|
@ -415,8 +400,35 @@ class module(osv.osv):
|
|||
known_dep_ids, exclude_states,context))
|
||||
return list(known_dep_ids)
|
||||
|
||||
def _button_immediate_function(self, cr, uid, ids, function, context=None):
|
||||
function(cr, uid, ids, context=context)
|
||||
|
||||
cr.commit()
|
||||
_, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
||||
|
||||
config = pool.get('res.config').next(cr, uid, [], context=context) or {}
|
||||
if config.get('type') not in ('ir.actions.reload', 'ir.actions.act_window_close'):
|
||||
return config
|
||||
|
||||
# reload the client; open the first available root menu
|
||||
menu_obj = self.pool.get('ir.ui.menu')
|
||||
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
||||
|
||||
return {
|
||||
'type' : 'ir.actions.client',
|
||||
'tag' : 'reload',
|
||||
'params' : {'menu_id' : menu_ids and menu_ids[0] or False}
|
||||
}
|
||||
|
||||
def button_immediate_uninstall(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Uninstall the selected module(s) immediately and fully,
|
||||
returns the next res.config action to execute
|
||||
"""
|
||||
return self._button_immediate_function(cr, uid, ids, self.button_uninstall, context=context)
|
||||
|
||||
def button_uninstall(self, cr, uid, ids, context=None):
|
||||
if any(m.name == 'base' for m in self.browse(cr, uid, ids)):
|
||||
if any(m.name == 'base' for m in self.browse(cr, uid, ids, context=context)):
|
||||
raise orm.except_orm(_('Error'), _("The `base` module cannot be uninstalled"))
|
||||
dep_ids = self.downstream_dependencies(cr, uid, ids, context=context)
|
||||
self.write(cr, uid, ids + dep_ids, {'state': 'to remove'})
|
||||
|
@ -426,6 +438,13 @@ class module(osv.osv):
|
|||
self.write(cr, uid, ids, {'state': 'installed'})
|
||||
return True
|
||||
|
||||
def button_immediate_upgrade(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Upgrade the selected module(s) immediately and fully,
|
||||
return the next res.config action to execute
|
||||
"""
|
||||
return self._button_immediate_function(cr, uid, ids, self.button_upgrade, context=context)
|
||||
|
||||
def button_upgrade(self, cr, uid, ids, context=None):
|
||||
depobj = self.pool.get('ir.module.module.dependency')
|
||||
todo = self.browse(cr, uid, ids, context=context)
|
||||
|
|
|
@ -117,8 +117,8 @@
|
|||
<h1><field name="shortdesc"/></h1>
|
||||
<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_upgrade" states="installed" string="Upgrade" type="object" class="oe_highlight"/>
|
||||
<button name="button_uninstall" states="installed" string="Uninstall" type="object"
|
||||
<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_cancel" states="to remove" string="Cancel Uninstall" type="object"/>
|
||||
<button name="button_upgrade_cancel" states="to upgrade" string="Cancel Upgrade" type="object"/>
|
||||
|
|
Loading…
Reference in New Issue