base: modify the the reload menu message
[odoo/odoo.git] / bin / addons / base / module / wizard / wizard_module_upgrade.py
1 # -*- coding: iso-8859-1 -*-
2 ##############################################################################
3 #
4 # Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 #                    Fabien Pinckaers <fp@tiny.Be>
6 #
7 # WARNING: This program as such is intended to be used by professional
8 # programmers who take the whole responsability of assessing all potential
9 # consequences resulting from its eventual inadequacies and bugs
10 # End users who are looking for a ready-to-use solution with commercial
11 # garantees and support are strongly adviced to contract a Free Software
12 # Service Company
13 #
14 # This program is Free Software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27 #
28 ##############################################################################
29
30 import wizard
31 import pooler
32
33 view_form_end = """<?xml version="1.0"?>
34 <form string="System upgrade done">
35         <separator string="System upgrade done"/>
36         <label align="0.0" string="The modules have been upgraded / installed !" colspan="4"/>
37         <label align="0.0" string="You may have to reinstall some language pack." colspan="4"/>
38         <label align="0.0" string="We suggest you to reload the menu tab (Ctrl+t Ctrl+r)." colspan="4"/>
39 </form>"""
40
41 view_form = """<?xml version="1.0"?>
42 <form string="System Upgrade">
43         <image name="gtk-info" size="64" colspan="2"/>
44         <group colspan="2" col="4">
45                 <label align="0.0" string="Your system will be upgraded." colspan="4"/>
46                 <label align="0.0" string="Note that this operation my take a few minutes." colspan="4"/>
47                 <separator string="Modules to update"/>
48                 <field name="module_info" nolabel="1" colspan="4"/>
49         </group>
50 </form>"""
51
52 view_field = {
53         "module_info": {'type':'text', 'string':'Modules', 'readonly':True}
54 }
55
56 class wizard_info_get(wizard.interface):
57         def _get_install(self, cr, uid, data, context):
58                 pool=pooler.get_pool(cr.dbname)
59                 ids = pool.get('ir.module.module').search(cr, uid, [
60                         ('state','<>','uninstalled'),
61                         ('state','<>','installed'),
62                         ('state','<>','uninstallable')])
63                 res = pool.get('ir.module.module').read(cr, uid, ids, ['name','state'], context)
64                 return {'module_info':'\n'.join(map(lambda x: x['name']+' : '+x['state'], res))}
65
66         def _upgrade_module(self, cr, uid, data, context):
67                 (db, pool)=pooler.restart_pool(cr.dbname, update_module=True)
68                 return {}
69
70         states = {
71                 'init': {
72                         'actions': [_get_install], 
73                         'result': {'type':'form', 'arch':view_form, 'fields': view_field, 'state':[('end','Cancel','gtk-cancel'),('start','Start Upgrade','gtk-ok')]}
74                 },
75                 'start': {
76                         'actions': [_upgrade_module], 
77                         'result': {'type':'form', 'arch':view_form_end, 'fields': {}, 'state':[('end','Close','gtk-close')]}
78                 },
79         }
80 wizard_info_get('module.upgrade')
81