Add Install / Upgrade Module wizard

This commit is contained in:
ced@b2ck.com committed 2007-12-29 18:44:55 +01:00
1 parent c8f3698135
commit 08d95e3e81
2 files changed
+133 -2

No files matched your search

+78
View File
@@ -8,6 +8,7 @@ import trytond.tools as tools
from trytond.module import ADDONS_PATH
from trytond.osv.orm import ExceptORM
from trytond.wizard import Wizard, WizardOSV
from trytond.pooler import get_db, restart_pool
VER_REGEXP = re.compile(
"^(\\d+)((\\.\\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\\d*)*)(-r(\\d+))?$")
@@ -620,3 +621,80 @@ class ModuleUpdateList(Wizard):
}
ModuleUpdateList()
class ModuleInstallUpgradeInit(WizardOSV):
_name = 'ir.module.module.install_upgrade.init'
_columns = {
'module_info': fields.Text('Modules to update', readonly=True),
'module_download': fields.Text('Modules to download', readonly=True),
}
ModuleInstallUpgradeInit()
class ModuleInstallUpgradeStart(WizardOSV):
_name = 'ir.module.module.install_upgrade.start'
_columns = {
}
ModuleInstallUpgradeStart()
class ModuleInstallUpgrade(Wizard):
"Install / Upgrade modules"
_name = 'ir.module.module.install_upgrade'
def _get_install(self, cursor, user, data, context):
module_obj = self.pool.get('ir.module.module')
module_ids = module_obj.search(cursor, user, [
('state', 'in', ['to upgrade', 'to remove', 'to install']),
], context=context)
modules = module_obj.browse(cursor, user, module_ids, context=context)
url = module_obj.download(cursor, user, module_ids, download=False,
context=context)
return {
'module_info': '\n'.join([x.name + ': ' + x.state \
for x in modules]),
'module_download': '\n'.join(url),
}
def _upgrade_module(self, cursor, user, data, context):
module_obj = self.pool.get('ir.module.module')
dbname = cursor.dbname
db = get_db(dbname)
cursor = db.cursor()
module_ids = module_obj.search(cursor, user, [
('state', 'in', ['to upgrade', 'to remove', 'to install']),
], context=context)
module_obj.download(cursor, user, module_ids, context=context)
cursor.commit()
cursor.close()
restart_pool(dbname, update_module=True)
return {}
states = {
'init': {
'actions': [_get_install],
'result': {
'type': 'form',
'object': 'ir.module.module.install_upgrade.init',
'state': [
('end', 'Cancel', 'gtk-cancel'),
('start', 'Start Upgrade', 'gtk-ok', True),
],
},
},
'start': {
'actions': [_upgrade_module],
'result': {
'type': 'form',
'object': 'ir.module.module.install_upgrade.start',
'state': [
('end', 'Close', 'gtk-close', True),
],
},
},
}
ModuleInstallUpgrade()
+55 -2
View File
@@ -103,7 +103,7 @@
<field name="name">Update Module List</field>
<field name="wiz_name">ir.module.module.update_list</field>
</record>
<record model="ir.ui.view" id="module_update_list_init">
<record model="ir.ui.view" id="module_update_list_init_view_form">
<field name="name">ir.module.module.update_list.init.form</field>
<field name="model">ir.module.module.update_list.init</field>
<field name="type">form</field>
@@ -117,7 +117,7 @@
]]>
</field>
</record>
<record model="ir.ui.view" id="module_update_list_update">
<record model="ir.ui.view" id="module_update_list_update_view_form">
<field name="name">ir.module.module.update_list.update.form</field>
<field name="model">ir.module.module.update_list.update</field>
<field name="type">form</field>
@@ -134,5 +134,58 @@
action="act_module_update_list"
type="wizard"
id="menu_module_update_list"/>
<record model="ir.actions.wizard" id="act_module_install_upgrade">
<field name="name">Install / Upgrade Modules</field>
<field name="wiz_name">ir.module.module.install_upgrade</field>
</record>
<record model="ir.ui.view" id="module_install_upgrade_init_view_form">
<field name="name">ir.module.module.install_upgrade.init.form</field>
<field name="model">ir.module.module.install_upgrade.init</field>
<field name="type">form</field>
<field name="arch" type="xml">
<![CDATA[
<form string="System Upgrade">
<image name="gtk-dialog-info" 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"/>
<separator string="Modules to download"/>
<field name="module_download" nolabel="1" colspan="4"/>
</group>
</form>
]]>
</field>
</record>
<record model="ir.ui.view" id="module_install_upgrade_start_view_form">
<field name="name">ir.module.module.install_upgrade.start.form</field>
<field name="model">ir.module.module.install_upgrade.start</field>
<field name="type">form</field>
<field name="arch" type="xml">
<![CDATA[
<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 reload the menu tab (Ctrl+t Ctrl+r)."
colspan="4"/>
</form>
]]>
</field>
</record>
<menuitem name="Administration/IR/Modules/Install \ Upgrade Modules"
action="act_module_install_upgrade"
type="wizard"
id="menu_module_install_upgrade"/>
</data>
</terp>