[REVERT]: Applied reverse changes for revno:3358
bzr revid: rpa@tinyerp.com-20110323121204-58g0hzqg5gz7f9yg
This commit is contained in:
parent
a384b6c137
commit
62cb6ff7cc
|
@ -200,7 +200,6 @@ class module(osv.osv):
|
|||
|
||||
def _name_uniq_msg(self, cr, uid, ids, context=None):
|
||||
return _('The name of the module must be unique !')
|
||||
|
||||
def _certificate_uniq_msg(self, cr, uid, ids, context=None):
|
||||
return _('The certificate ID of the module must be unique !')
|
||||
|
||||
|
@ -286,42 +285,8 @@ class module(osv.osv):
|
|||
demo = demo or mdemo
|
||||
return demo
|
||||
|
||||
def upgrade(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.module.module')
|
||||
ids = mod_obj.search(cr, uid, [('state', 'in', ['to upgrade', 'to remove', 'to install'])])
|
||||
unmet_packages = []
|
||||
mod_dep_obj = self.pool.get('ir.module.module.dependency')
|
||||
for mod in mod_obj.browse(cr, uid, ids, context=context):
|
||||
depends_mod_ids = mod_dep_obj.search(cr, uid, [('module_id', '=', mod.id)], context=context)
|
||||
for dep_mod in mod_dep_obj.browse(cr, uid, depends_mod_ids):
|
||||
if dep_mod.state in ('unknown','uninstalled'):
|
||||
unmet_packages.append(dep_mod.name)
|
||||
if len(unmet_packages):
|
||||
raise osv.except_osv(_('Unmet dependency !'), _('Following modules are not installed or unknown: %s') % ('\n\n' + '\n'.join(unmet_packages)))
|
||||
mod_obj.download(cr, uid, ids, context=context)
|
||||
cr.commit()
|
||||
_db, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
||||
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_upgrade_install')
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'base.module.upgrade',
|
||||
'views': [(id2, 'form')],
|
||||
'view_id': False,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy':True,
|
||||
}
|
||||
|
||||
def button_install(self, cr, uid, ids, context=None):
|
||||
self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
|
||||
res = self.upgrade(cr, uid, ids, context=context)
|
||||
return res
|
||||
|
||||
return self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
|
||||
|
||||
def button_install_cancel(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})
|
||||
|
@ -340,41 +305,49 @@ class module(osv.osv):
|
|||
res = cr.fetchall()
|
||||
if res:
|
||||
raise orm.except_orm(_('Error'), _('Some installed modules depend on the module you plan to Uninstall :\n %s') % '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res)))
|
||||
|
||||
self.write(cr, uid, ids, {'state': 'to remove'})
|
||||
self.upgrade(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def button_uninstall_cancel(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'installed'})
|
||||
return True
|
||||
|
||||
|
||||
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)
|
||||
self.update_list(cr, uid)
|
||||
|
||||
i = 0
|
||||
while i<len(todo):
|
||||
mod = todo[i]
|
||||
i += 1
|
||||
if mod.state not in ('installed','to upgrade'):
|
||||
raise orm.except_orm(_('Error'),
|
||||
_("Can not upgrade module '%s'. It is not installed.") % (mod.name,))
|
||||
self.check_external_dependencies(mod.name, 'to upgrade')
|
||||
iids = depobj.search(cr, uid, [('name', '=', mod.name)], context=context)
|
||||
for dep in depobj.browse(cr, uid, iids, context=context):
|
||||
if dep.module_id.state=='installed' and dep.module_id not in todo:
|
||||
todo.append(dep.module_id)
|
||||
|
||||
ids = map(lambda x: x.id, todo)
|
||||
self.write(cr, uid, ids, {'state':'to upgrade'}, context=context)
|
||||
|
||||
to_install = []
|
||||
for mod in todo:
|
||||
for dep in mod.dependencies_id:
|
||||
if dep.state == 'unknown':
|
||||
raise orm.except_orm(_('Error'), _('You try to upgrade a module that depends on the module: %s.\nBut this module is not available in your system.') % (dep.name,))
|
||||
if dep.state == 'installed':
|
||||
if dep.state == 'uninstalled':
|
||||
ids2 = self.search(cr, uid, [('name','=',dep.name)])
|
||||
to_install.extend(ids2)
|
||||
res = self.upgrade(cr, uid, ids, context=context)
|
||||
return res
|
||||
|
||||
self.button_install(cr, uid, to_install, context=context)
|
||||
return True
|
||||
|
||||
def button_upgrade_cancel(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'installed'})
|
||||
return True
|
||||
|
||||
def button_update_translations(self, cr, uid, ids, context=None):
|
||||
self.update_translations(cr, uid, ids)
|
||||
return True
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
<newline/>
|
||||
<field name="state" readonly="1" select="1"/>
|
||||
<group col="6" colspan="2">
|
||||
<button name="button_install" states="uninstalled" string="Install" icon="terp-gtk-jump-to-ltr" type="object"/>
|
||||
<button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object"/>
|
||||
<button name="button_install_cancel" states="to install" string="Cancel Install" icon="gtk-cancel" type="object"/>
|
||||
<button name="button_uninstall" states="installed" string="Uninstall (beta)" icon="terp-dialog-close" type="object"/>
|
||||
<button name="button_uninstall_cancel" states="to remove" string="Cancel Uninstall" icon="gtk-cancel" type="object"/>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import pooler
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
|
@ -80,6 +81,36 @@ class base_module_upgrade(osv.osv_memory):
|
|||
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(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.module.module')
|
||||
ids = mod_obj.search(cr, uid, [('state', 'in', ['to upgrade', 'to remove', 'to install'])])
|
||||
unmet_packages = []
|
||||
mod_dep_obj = self.pool.get('ir.module.module.dependency')
|
||||
for mod in mod_obj.browse(cr, uid, ids):
|
||||
depends_mod_ids = mod_dep_obj.search(cr, uid, [('module_id', '=', mod.id)])
|
||||
for dep_mod in mod_dep_obj.browse(cr, uid, depends_mod_ids):
|
||||
if dep_mod.state in ('unknown','uninstalled'):
|
||||
unmet_packages.append(dep_mod.name)
|
||||
if len(unmet_packages):
|
||||
raise osv.except_osv(_('Unmet dependency !'), _('Following modules are not installed or unknown: %s') % ('\n\n' + '\n'.join(unmet_packages)))
|
||||
mod_obj.download(cr, uid, ids, context=context)
|
||||
cr.commit()
|
||||
_db, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
||||
|
||||
data_obj = pool.get('ir.model.data')
|
||||
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_upgrade_install')
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'base.module.upgrade',
|
||||
'views': [(id2, 'form')],
|
||||
'view_id': False,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
def config(self, cr, uid, ids, context=None):
|
||||
return self.pool.get('res.config').next(cr, uid, [], context=context)
|
||||
|
|
|
@ -30,6 +30,18 @@
|
|||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
name="Apply Scheduled Upgrades"
|
||||
action="action_view_base_module_upgrade"
|
||||
id="menu_view_base_module_upgrade"
|
||||
parent="menu_management"
|
||||
sequence="3"/>
|
||||
|
||||
<act_window id="action_view_base_module_upgrade_window"
|
||||
key2="client_action_multi" name="Apply Scheduled Upgrades"
|
||||
res_model="base.module.upgrade" src_model="ir.module.module"
|
||||
view_mode="form" target="new" view_type="form" />
|
||||
|
||||
<record id="view_base_module_upgrade_install" model="ir.ui.view">
|
||||
<field name="name">Module Upgrade Install</field>
|
||||
<field name="model">base.module.upgrade</field>
|
||||
|
|
Loading…
Reference in New Issue