From f917fe27b07a4e95b6bc4d02b9308f0dd34bfbe9 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Thu, 26 Aug 2010 15:48:50 +0530 Subject: [IMP] Import module wizard convert into osv memory wizard bzr revid: ksa@tinyerp.co.in-20100826101850-e8tsrqre2ksdpr3b --- .../base/module/wizard/base_module_import.py | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 bin/addons/base/module/wizard/base_module_import.py (limited to 'bin/addons/base/module/wizard/base_module_import.py') 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 (). +# +# 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 . +# +############################################################################## + + +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() + -- cgit v1.2.3