BASE:
Function to remove installed modules bzr revid: pinky-b26b2a3b41980a56a595a294b8915b74c9b35728master
parent
e4449ce90f
commit
148efe9c55
|
@ -233,10 +233,10 @@ def register_classes():
|
|||
imp.load_module(m, *imp.find_module(m))
|
||||
|
||||
def load_modules(db, force_demo=False, status={}, update_module=False):
|
||||
cr = db.cursor()
|
||||
force = []
|
||||
if force_demo:
|
||||
force.append('demo')
|
||||
cr = db.cursor()
|
||||
if update_module:
|
||||
cr.execute("select name from ir_module_module where state in ('installed', 'to install', 'to upgrade')")
|
||||
else:
|
||||
|
@ -244,6 +244,28 @@ def load_modules(db, force_demo=False, status={}, update_module=False):
|
|||
module_list = [name for (name,) in cr.fetchall()]
|
||||
graph = create_graph(module_list, force)
|
||||
load_module_graph(cr, graph, status)
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
if update_module:
|
||||
cr.execute("select id,name from ir_module_module where state in ('to remove')")
|
||||
for mod_id, mod_name in cr.fetchall():
|
||||
cr.execute('select model,res_id from ir_model_data where not noupdate and module=%s order by id desc', (mod_name,))
|
||||
for rmod,rid in cr.fetchall():
|
||||
mod_table = pool.get(rmod)._table
|
||||
print rmod, mod_table
|
||||
cr.execute('delete from '+mod_table+' where id=%d', (rid,))
|
||||
cr.commit()
|
||||
#
|
||||
# TODO: remove menu without actions of childs
|
||||
#
|
||||
cr.execute('''delete from
|
||||
ir_ui_menu
|
||||
where
|
||||
(id not in (select parent_id from ir_ui_menu where parent_id is not null))
|
||||
and
|
||||
(id not in (select res_id from ir_values where model='ir.ui.menu'))''')
|
||||
|
||||
cr.execute("update ir_module_module set state=%s where state in ('to remove')", ('uninstalled', ))
|
||||
cr.commit()
|
||||
cr.commit()
|
||||
cr.close()
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import re
|
|||
import urllib
|
||||
import os
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
from osv import fields, osv, orm
|
||||
|
||||
class module_repository(osv.osv):
|
||||
_name = "ir.module.repository"
|
||||
|
@ -135,6 +135,20 @@ class module(osv.osv):
|
|||
return True
|
||||
|
||||
def button_uninstall(self, cr, uid, ids, context={}):
|
||||
for module in self.browse(cr, uid, ids):
|
||||
cr.execute('''select m.state,m.name
|
||||
from
|
||||
ir_module_module_dependency d
|
||||
join
|
||||
ir_module_module m on (d.module_id=m.id)
|
||||
where
|
||||
d.name=%s and
|
||||
m.state not in ('uninstalled','uninstallable','to remove')''', (module.name,))
|
||||
res = cr.fetchall()
|
||||
if res:
|
||||
print 'Error !'
|
||||
print 'The module you are trying to remove depends on installed modules :\n' + '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res))
|
||||
raise orm.except_orm('Error', 'The module you are trying to remove depends on installed modules :\n' + '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res)))
|
||||
self.write(cr, uid, ids, {'state': 'to remove'})
|
||||
return True
|
||||
|
||||
|
|
|
@ -89,10 +89,10 @@
|
|||
<!--
|
||||
<button string="Cancel Upgrade" name="button_upgrade_cancel" type="object" states="to upgrade"/>
|
||||
<button string="Cancel Remove" name="button_remove_cancel" type="object" states="to remove"/>
|
||||
<button string="Uninstall" name="button_uninstall" type="object" states="installed"/>
|
||||
-->
|
||||
<button string="Uninstall" name="button_uninstall" type="object" states="installed"/>
|
||||
<button string="Upgrade" name="button_upgrade" type="object" states="installed"/>
|
||||
<!--
|
||||
<!--
|
||||
<button string="Update translations" name="button_update_translations" type="object" states="installed"/>
|
||||
-->
|
||||
</group>
|
||||
|
|
Loading…
Reference in New Issue