summaryrefslogtreecommitdiff
path: root/bin/addons/base/module/wizard
diff options
context:
space:
mode:
authorpinky <>2006-12-07 13:41:40 +0000
committerpinky <>2006-12-07 13:41:40 +0000
commit004a0b996ff8f269451e07346f71a129a1f3fbaf (patch)
tree48f43c1fc2ca4c1f4d5648e7e73553d3f4ccae06 /bin/addons/base/module/wizard
New trunk
bzr revid: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
Diffstat (limited to 'bin/addons/base/module/wizard')
-rw-r--r--bin/addons/base/module/wizard/__init__.py35
-rw-r--r--bin/addons/base/module/wizard/add_new.py100
-rw-r--r--bin/addons/base/module/wizard/wizard_export_lang.py91
-rw-r--r--bin/addons/base/module/wizard/wizard_import_lang.py75
-rw-r--r--bin/addons/base/module/wizard/wizard_install_module.py67
-rw-r--r--bin/addons/base/module/wizard/wizard_module_info_get.py46
-rw-r--r--bin/addons/base/module/wizard/wizard_module_lang_install.py83
-rw-r--r--bin/addons/base/module/wizard/wizard_module_upgrade.py81
-rw-r--r--bin/addons/base/module/wizard/wizard_update_module.py61
9 files changed, 639 insertions, 0 deletions
diff --git a/bin/addons/base/module/wizard/__init__.py b/bin/addons/base/module/wizard/__init__.py
new file mode 100644
index 00000000000..d74449872c0
--- /dev/null
+++ b/bin/addons/base/module/wizard/__init__.py
@@ -0,0 +1,35 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard_install_module
+import wizard_update_module
+import wizard_module_upgrade
+import wizard_module_info_get
+import wizard_module_lang_install
+import add_new
+import wizard_export_lang
+import wizard_import_lang
diff --git a/bin/addons/base/module/wizard/add_new.py b/bin/addons/base/module/wizard/add_new.py
new file mode 100644
index 00000000000..63d7a2359dd
--- /dev/null
+++ b/bin/addons/base/module/wizard/add_new.py
@@ -0,0 +1,100 @@
+##############################################################################
+#
+# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be)
+#
+# $Id$
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contact a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import os
+import re
+import glob
+import time
+import imp
+
+import tools
+import wizard
+import pooler
+
+module_name_re = re.compile('.*addons.(.*?).__terp__.py$')
+
+_info_arch = '''<?xml version="1.0"?>
+<form string="Scan for new modules">
+ <label string="This function will check if you installed new modules in the 'addons' path of your server installation." colspan="4" />
+</form>
+'''
+_info_fields = {}
+
+def get_module_info(name):
+ try:
+ f = file(os.path.join(tools.config['addons_path'], name, '__terp__.py'), 'r')
+ data = f.read()
+ info = eval(data)
+ f.close()
+ except:
+ return {}
+ return info
+
+class wizard_install_module(wizard.interface):
+ def watch_dir(self, cr, uid, data, context):
+ mod_obj = pooler.get_pool(cr.dbname).get('ir.module.module')
+ all_mods = mod_obj.read(cr, uid, mod_obj.search(cr, uid, []), ['name', 'state'])
+ known_modules = set([x['name'] for x in all_mods])
+ ls_ad = glob.glob(os.path.join(tools.config['addons_path'], '*', '__terp__.py'))
+ modules = set([module_name_re.match(name).group(1) for name in ls_ad])
+ new_modules = modules - known_modules
+ for module in new_modules:
+ terp = get_module_info(module)
+ if not terp.get('installable', True):
+ continue
+ imp.load_module(module, *imp.find_module(module))
+ mod_id = mod_obj.create(cr, uid, {
+ 'name': module,
+ 'state': 'uninstalled',
+ 'description': terp.get('description', ''),
+ 'shortdesc': terp.get('name', ''),
+ 'author': terp.get('author', 'Unknown')})
+ dependencies = terp.get('depends', [])
+ for d in dependencies:
+ cr.execute('insert into ir_module_module_dependency (module_id,name) values (%s, %s)', (mod_id, d))
+ for module in known_modules:
+ terp = get_module_info(module)
+ if terp.get('installable', True):
+ for mod in all_mods:
+ if mod['name'] == module and mod['state'] == 'uninstallable':
+ mod_obj.write(cr, uid, [mod['id']], {'state': 'uninstalled'})
+ return {}
+
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch': _info_arch, 'fields': _info_fields, 'state':[('end','Cancel','gtk-cancel'),('addmod','Check new modules','gtk-ok')]}
+ },
+ 'addmod': {
+ 'actions': [watch_dir],
+ 'result': {'type':'state', 'state':'end'}
+ },
+ }
+wizard_install_module('module.module.scan')
+
diff --git a/bin/addons/base/module/wizard/wizard_export_lang.py b/bin/addons/base/module/wizard/wizard_export_lang.py
new file mode 100644
index 00000000000..212e6b459c2
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_export_lang.py
@@ -0,0 +1,91 @@
+# -*- coding: iso-8859-1 -*-
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@tiny.Be>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard
+import tools
+import base64
+import StringIO
+import csv
+import pooler
+
+view_form_init="""<?xml version="1.0"?>
+<form string="Export language">
+ <image name="gtk-info" size="64" colspan="2"/>
+ <group colspan="2" col="4">
+ <separator string="Export translation file" colspan="4"/>
+ <label align="0.0" string="Choose a language to export:" colspan="4"/>
+ <field name="lang" colspan="4"/>
+ </group>
+</form>"""
+
+view_form_finish="""<?xml version="1.0"?>
+<form string="Export language">
+ <image name="gtk-info" size="64" colspan="2"/>
+ <group colspan="2" col="4">
+ <separator string="Export done" colspan="4"/>
+ <field name="data" readonly="1" colspan="3"/>
+ <label align="0.0" string="Save this document to a .CSV file and open it with\n your favourite spreadsheet software. The file\n encoding is UTF-8. You have to translate the latest\n column before reimporting it." colspan="4"/>
+ </group>
+</form>"""
+
+class wizard_export_lang(wizard.interface):
+ def _get_language(self, cr, uid, context):
+ lang_obj=pooler.get_pool(cr.dbname).get('res.lang')
+ ids=lang_obj.search(cr, uid, [('active', '=', True),])
+ langs=lang_obj.browse(cr, uid, ids)
+ return [(lang.code, lang.translatable and lang.name or 'New language') for lang in langs]
+
+ def _get_file(self, cr, uid, data, context):
+ file=tools.trans_generate(data['form']['lang'], 'all')
+ buf=StringIO.StringIO()
+ writer=csv.writer(buf)
+ for row in file:
+ writer.writerow(row)
+ del file
+ out=base64.encodestring(buf.getvalue())
+ buf.close()
+ return {'data': out}
+
+ fields_form={
+ 'lang': {'string':'Language', 'type':'selection', 'selection':_get_language,},
+ }
+ fields_form_finish={
+ 'data': {'string':'File', 'type':'binary', 'readonly': True,},
+ }
+ states={
+ 'init':{
+ 'actions':[],
+ 'result':{'type':'form', 'arch':view_form_init, 'fields': fields_form, 'state':[('end', 'Cancel', 'gtk-cancel'),('finish', 'Ok', 'gtk-ok')]}
+ },
+ 'finish':{
+ 'actions':[_get_file],
+ 'result':{'type':'form', 'arch':view_form_finish, 'fields': fields_form_finish, 'state':[('end', 'Close', 'gtk-cancel')]}
+ },
+ }
+wizard_export_lang('module.lang.export')
diff --git a/bin/addons/base/module/wizard/wizard_import_lang.py b/bin/addons/base/module/wizard/wizard_import_lang.py
new file mode 100644
index 00000000000..226bece1ace
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_import_lang.py
@@ -0,0 +1,75 @@
+# -*- coding: iso-8859-1 -*-
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@tiny.Be>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard
+import tools
+import base64
+import pooler
+
+view_form="""<?xml version="1.0"?>
+<form string="Import language">
+ <image name="gtk-info" size="64" colspan="2"/>
+ <group colspan="2" col="4">
+ <separator string="Import new language" colspan="4"/>
+ <field name="name"/>
+ <field name="code"/>
+ <field name="data" colspan="3"/>
+ <label string="You have to import a .CSV file wich is encoded in UTF-8.\nPlease check that the first line of your file is:" colspan="4" align="0.0"/>
+ <label string="type,name,res_id,src,value" colspan="4"/>
+ </group>
+</form>"""
+
+class wizard_import_lang(wizard.interface):
+ def _import_lang(self, cr, uid, data, context):
+ form=data['form']
+ lang_obj=pooler.get_pool(cr.dbname).get('res.lang')
+ ids=lang_obj.search(cr, uid, [('code', '=', form['code'])])
+ if ids:
+ lang_obj.write(cr, uid, ids, {'name': form['name']})
+ else:
+ lang_obj.create(cr, uid, {'code': form['code'], 'name': form['name']})
+ buf=base64.decodestring(data['form']['data']).split('\n')
+ tools.trans_load_data(cr.dbname, buf, data['form']['code'])
+ return {}
+ fields_form={
+ 'name':{'string':'Language name', 'type':'char', 'size':64, 'required':True},
+ 'code':{'string':'Code (eg:en_US)', 'type':'char', 'size':5, 'required':True},
+ 'data':{'string':'File', 'type':'binary', 'required':True},
+ }
+ states={
+ 'init':{
+ 'actions':[],
+ 'result':{'type':'form', 'arch':view_form, 'fields':fields_form, 'state':[('end', 'Cancel', 'gtk-cancel'), ('finish', 'Ok', 'gtk-ok')]}
+ },
+ 'finish':{
+ 'actions':[],
+ 'result':{'type':'action', 'action':_import_lang, 'state':'end'}
+ },
+ }
+wizard_import_lang('module.lang.import')
diff --git a/bin/addons/base/module/wizard/wizard_install_module.py b/bin/addons/base/module/wizard/wizard_install_module.py
new file mode 100644
index 00000000000..71a6be50848
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_install_module.py
@@ -0,0 +1,67 @@
+# -*- coding: iso-8859-1 -*-
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard
+import netsvc
+
+#TODO: upgraded modules
+#TODO: removed modules
+additional_changes_form = '''<?xml version="1.0"?>
+<form string="Additional modules">
+ <label string="The following additional modules need to be installed:"/>
+ <newline/>
+ <field name="additional"/>
+</form>'''
+
+additional_changes_fields = {
+ 'additional': {'string':'Additional modules', 'type':'one2many', 'relation':'ir.module.module', 'readonly':True},
+}
+
+class wizard_install_module(wizard.interface):
+ def _get_value(self, cr, uid, data, context):
+ service = netsvc.LocalService("object_proxy")
+ extra = service.execute(cr.dbname, uid, 'ir.module.module', 'get_extra_modules', data['ids'])
+ return {'additional': extra}
+
+ def _install_module(self, cr, uid, data, context):
+ service = netsvc.LocalService("object_proxy")
+ res = service.execute(cr.dbname, uid, 'ir.module.module', 'install', data['ids'])
+ return {}
+
+ states = {
+ 'init': {
+ 'actions': [_get_value],
+ 'result': {'type':'form', 'arch':additional_changes_form, 'fields':additional_changes_fields, 'state':[('install','Install'), ('end','Cancel')]}
+ },
+ 'install': {
+ 'actions': [_install_module],
+ 'result': {'type':'state', 'state':'end'}
+ },
+ }
+wizard_install_module('module.module.install')
+
diff --git a/bin/addons/base/module/wizard/wizard_module_info_get.py b/bin/addons/base/module/wizard/wizard_module_info_get.py
new file mode 100644
index 00000000000..124a6820b8b
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_module_info_get.py
@@ -0,0 +1,46 @@
+# -*- coding: iso-8859-1 -*-
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@tiny.Be>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard
+import netsvc
+
+class wizard_info_get(wizard.interface):
+ def _update_module(self, cr, uid, data, context):
+ service = netsvc.LocalService("object_proxy")
+ service.execute(cr.dbname, uid, 'ir.module.module', 'info_get', data['ids'])
+ return {}
+
+ states = {
+ 'init': {
+ 'actions': [_update_module],
+ 'result': {'type':'state', 'state':'end'}
+ },
+ }
+wizard_info_get('module.info_get')
+
diff --git a/bin/addons/base/module/wizard/wizard_module_lang_install.py b/bin/addons/base/module/wizard/wizard_module_lang_install.py
new file mode 100644
index 00000000000..14f3e867a50
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_module_lang_install.py
@@ -0,0 +1,83 @@
+# -*- coding: iso-8859-1 -*-
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@tiny.Be>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard
+import tools
+
+view_form_end = """<?xml version="1.0"?>
+<form string="Language file loaded.">
+ <image name="gtk-info" size="64" colspan="2"/>
+ <group colspan="2" col="4">
+ <separator string="Installation done" colspan="4"/>
+ <label align="0.0" string="The selected language has been successfully installed.\nYou must change the preferences of the user and open a new menu to view changes." colspan="4"/>
+ </group>
+</form>"""
+
+view_form = """<?xml version="1.0"?>
+<form string="System Upgrade">
+ <image name="gtk-info" size="64" colspan="2"/>
+ <group colspan="2" col="4">
+ <separator string="System Upgrade" colspan="4"/>
+ <label align="0.0" string="Choose a language to install:" colspan="4"/>
+ <field name="lang" colspan="4"/>
+ <label align="0.0" string="Note that this operation may take a few minutes." colspan="4"/>
+ </group>
+</form>"""
+
+
+class wizard_lang_install(wizard.interface):
+ def _lang_install(self, cr, uid, data, context):
+ print cr, uid, data, context
+
+ lang = data['form']['lang']
+ if lang and lang != 'en_EN':
+ filename = tools.config["root_path"] + "/i18n/" + lang + ".csv"
+ tools.trans_load(cr.dbname, filename, lang)
+ return {}
+
+ def _get_language(sel, cr, uid, context):
+ return tools.scan_languages()
+
+ fields_form = {
+ 'lang': {'string':'Language', 'type':'selection', 'selection':_get_language,
+ },
+ }
+
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':view_form, 'fields': fields_form, 'state':[('end','Cancel','gtk-cancel'),('start','Start installation','gtk-ok')]}
+ },
+ 'start': {
+ 'actions': [_lang_install],
+ 'result': {'type':'form', 'arch':view_form_end, 'fields': {}, 'state':[('end','Ok','gtk-ok')]}
+ },
+ }
+wizard_lang_install('module.lang.install')
+
diff --git a/bin/addons/base/module/wizard/wizard_module_upgrade.py b/bin/addons/base/module/wizard/wizard_module_upgrade.py
new file mode 100644
index 00000000000..65cfaa66a50
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_module_upgrade.py
@@ -0,0 +1,81 @@
+# -*- coding: iso-8859-1 -*-
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@tiny.Be>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard
+import pooler
+
+view_form_end = """<?xml version="1.0"?>
+<form string="System upgrade done">
+ <separator string="System upgrade done"/>
+ <label align="0.0" string="The modules have been upgraded / installed !" colspan="4"/>
+ <label align="0.0" string="You may have to reinstall some language pack." colspan="4"/>
+ <label align="0.0" string="We suggest you to close all tabs and open a new menu window (Ctrl T)." colspan="4"/>
+</form>"""
+
+view_form = """<?xml version="1.0"?>
+<form string="System Upgrade">
+ <image name="gtk-info" size="64" colspan="2"/>
+ <group colspan="2" col="4">
+ <label align="0.0" string="Your system will be upgraded." colspan="4"/>
+ <label align="0.0" string="Note that this operation my take a few minutes." colspan="4"/>
+ <separator string="Modules to update"/>
+ <field name="module_info" nolabel="1" colspan="4"/>
+ </group>
+</form>"""
+
+view_field = {
+ "module_info": {'type':'text', 'string':'Modules', 'readonly':True}
+}
+
+class wizard_info_get(wizard.interface):
+ def _get_install(self, cr, uid, data, context):
+ pool=pooler.get_pool(cr.dbname)
+ ids = pool.get('ir.module.module').search(cr, uid, [
+ ('state','<>','uninstalled'),
+ ('state','<>','installed'),
+ ('state','<>','uninstallable')])
+ res = pool.get('ir.module.module').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, data, context):
+ (db, pool)=pooler.restart_pool(cr.dbname, update_module=True)
+ return {}
+
+ states = {
+ 'init': {
+ 'actions': [_get_install],
+ 'result': {'type':'form', 'arch':view_form, 'fields': view_field, 'state':[('end','Cancel','gtk-cancel'),('start','Start Upgrade','gtk-ok')]}
+ },
+ 'start': {
+ 'actions': [_upgrade_module],
+ 'result': {'type':'form', 'arch':view_form_end, 'fields': {}, 'state':[('end','Close','gtk-close')]}
+ },
+ }
+wizard_info_get('module.upgrade')
+
diff --git a/bin/addons/base/module/wizard/wizard_update_module.py b/bin/addons/base/module/wizard/wizard_update_module.py
new file mode 100644
index 00000000000..5a2ec58912b
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_update_module.py
@@ -0,0 +1,61 @@
+# -*- coding: iso-8859-1 -*-
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@tiny.Be>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import wizard
+import netsvc
+
+class wizard_update_module(wizard.interface):
+ def _update_module(self, cr, uid, data, context):
+ service = netsvc.LocalService("object_proxy")
+ service.execute(cr.dbname, uid, 'ir.module.module', 'update_list')
+ return {}
+
+ def _action_module_open(self, cr, uid, data, context):
+ return {
+ 'domain': "[]",
+ 'name': 'Open Module List',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'ir.module.module',
+ 'view_id': False,
+ 'type': 'ir.actions.act_window'
+ }
+
+ states = {
+ 'init': {
+ 'actions': [_update_module],
+ 'result': {'type':'state', 'state':'open_window'}
+ },
+ 'open_window': {
+ 'actions': [],
+ 'result': {'type': 'action', 'action': _action_module_open, 'state':'end'}
+ }
+ }
+wizard_update_module('module.module.update')
+