2006-12-07 13:41:40 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
2008-06-16 11:00:21 +00:00
|
|
|
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
|
|
|
#
|
|
|
|
# $Id$
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
|
|
|
# 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
|
2008-06-20 11:55:52 +00:00
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
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"/>
|
2007-07-12 15:31:01 +00:00
|
|
|
<label align="0.0" string="We suggest you to reload the menu tab (Ctrl+t Ctrl+r)." colspan="4"/>
|
2006-12-07 13:41:40 +00:00
|
|
|
</form>"""
|
|
|
|
|
|
|
|
view_form = """<?xml version="1.0"?>
|
|
|
|
<form string="System Upgrade">
|
2007-08-06 08:24:21 +00:00
|
|
|
<image name="gtk-dialog-info" colspan="2"/>
|
2006-12-07 13:41:40 +00:00
|
|
|
<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"/>
|
2007-08-01 14:03:37 +00:00
|
|
|
<separator string="Modules to download"/>
|
|
|
|
<field name="module_download" nolabel="1" colspan="4"/>
|
2006-12-07 13:41:40 +00:00
|
|
|
</group>
|
|
|
|
</form>"""
|
|
|
|
|
|
|
|
view_field = {
|
2007-08-01 14:03:37 +00:00
|
|
|
"module_info": {'type': 'text', 'string': 'Modules to update',
|
|
|
|
'readonly': True},
|
|
|
|
"module_download": {'type': 'text', 'string': 'Modules to download',
|
|
|
|
'readonly': True},
|
2006-12-07 13:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class wizard_info_get(wizard.interface):
|
|
|
|
def _get_install(self, cr, uid, data, context):
|
|
|
|
pool=pooler.get_pool(cr.dbname)
|
2007-07-30 13:35:27 +00:00
|
|
|
mod_obj = pool.get('ir.module.module')
|
|
|
|
ids = mod_obj.search(cr, uid, [
|
|
|
|
('state', 'in', ['to upgrade', 'to remove', 'to install'])])
|
2007-08-01 14:03:37 +00:00
|
|
|
res = mod_obj.read(cr, uid, ids, ['name','state'], context)
|
|
|
|
url = mod_obj.download(cr, uid, ids, download=False, context=context)
|
|
|
|
return {'module_info': '\n'.join(map(lambda x: x['name']+' : '+x['state'], res)),
|
|
|
|
'module_download': '\n'.join(url)}
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
def _upgrade_module(self, cr, uid, data, context):
|
2007-10-30 09:05:50 +00:00
|
|
|
db, pool = pooler.get_db_and_pool(cr.dbname)
|
|
|
|
cr = db.cursor()
|
2007-07-30 13:35:27 +00:00
|
|
|
mod_obj = pool.get('ir.module.module')
|
|
|
|
ids = mod_obj.search(cr, uid, [
|
|
|
|
('state', 'in', ['to upgrade', 'to remove', 'to install'])])
|
|
|
|
mod_obj.download(cr, uid, ids, context=context)
|
2007-10-30 09:05:50 +00:00
|
|
|
cr.commit()
|
|
|
|
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
2006-12-07 13:41:40 +00:00
|
|
|
return {}
|
|
|
|
|
|
|
|
states = {
|
|
|
|
'init': {
|
2008-06-20 13:20:21 +00:00
|
|
|
'actions': [_get_install],
|
2007-08-06 08:24:21 +00:00
|
|
|
'result': {'type':'form', 'arch':view_form, 'fields': view_field,
|
|
|
|
'state':[
|
|
|
|
('end', 'Cancel', 'gtk-cancel'),
|
|
|
|
('start', 'Start Upgrade', 'gtk-ok', True)
|
|
|
|
]
|
|
|
|
}
|
2006-12-07 13:41:40 +00:00
|
|
|
},
|
|
|
|
'start': {
|
2008-06-20 13:20:21 +00:00
|
|
|
'actions': [_upgrade_module],
|
|
|
|
'result': {'type':'form', 'arch':view_form_end, 'fields': {},
|
|
|
|
'state':[
|
|
|
|
('end', 'Close', 'gtk-close', True)
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2006-12-07 13:41:40 +00:00
|
|
|
wizard_info_get('module.upgrade')
|
|
|
|
|