summaryrefslogtreecommitdiff
path: root/bin/addons/base/module/wizard/base_module_import.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/addons/base/module/wizard/base_module_import.py')
-rw-r--r--bin/addons/base/module/wizard/base_module_import.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/bin/addons/base/module/wizard/base_module_import.py b/bin/addons/base/module/wizard/base_module_import.py
new file mode 100644
index 00000000000..fc28452c6dd
--- /dev/null
+++ b/bin/addons/base/module/wizard/base_module_import.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+import pooler
+import os
+import tools
+
+import zipfile
+from StringIO import StringIO
+import base64
+from tools.translate import _
+from osv import osv, fields
+
+class base_module_import(osv.osv_memory):
+ """ Import Module """
+
+ _name = "base.module.import"
+ _description = "Import Module"
+
+ _columns = {
+ 'module_file': fields.binary('Module .ZIP file', required=True),
+ }
+
+ def action_module_open(self, cr, uid, ids, context):
+ module_obj = self.pool.get('base.module.import')
+ data = module_obj.browse(cr, uid, ids , context=context)[0]
+ module_data = data.module_file
+
+ val =base64.decodestring(module_data)
+ fp = StringIO()
+ fp.write(val)
+ fdata = zipfile.ZipFile(fp, 'r')
+ fname = fdata.namelist()[0]
+ module_name = os.path.split(fname)[0]
+
+ return {
+ 'domain': str([('name', '=', module_name)]),
+ 'name': 'Module List',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'ir.module.module',
+ 'type': 'ir.actions.act_window',
+ }
+
+base_module_import()
+