1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
31 from StringIO import StringIO
34 finish_form ='''<?xml version="1.0"?>
35 <form string="Module import">
36 <label string="Module successfully imported !" colspan="4"/>
40 ask_form ='''<?xml version="1.0"?>
41 <form string="Module import">
42 <separator string="Module import" colspan="4"/>
43 <label string="Please give your module .ZIP file to import." colspan="4"/>
44 <field name="module_file"/>
49 'module_file': {'string': 'Module .ZIP file', 'type': 'binary', 'required': True},
52 class move_module_wizard(wizard.interface):
53 def importzip(self, cr, uid, data, context):
54 module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
55 module_data = data['form']['module_file']
57 val =base64.decodestring(module_data)
60 fdata = zipfile.ZipFile(fp, 'r')
61 fname = fdata.namelist()[0]
62 module_name = os.path.split(fname)[0]
64 ad = tools.config['addons_path']
66 fname = os.path.join(ad,module_name+'.zip')
68 fp = file(fname, 'wb')
72 raise wizard.except_wizard(_('Error !'), _('Can not create the module file: %s !') % (fname,) )
74 pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid)
75 return {'module_name': module_name}
77 def _action_module_open(self, cr, uid, data, context):
79 'domain': str([('name', '=', data['form']['module_name'])]),
80 'name': 'Module List',
82 'view_mode': 'tree,form',
83 'res_model': 'ir.module.module',
85 'type': 'ir.actions.act_window'
96 ('end', 'Cancel', 'gtk-cancel'),
97 ('import', 'Import module', 'gtk-ok', True)
102 'actions': [importzip],
107 'state':[('open_window','Close')]
112 'result': {'type': 'action', 'action': _action_module_open, 'state':'end'}
115 move_module_wizard('base.module.import')
117 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: