diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py
index e25b5f081c5..3d1a77065e9 100644
--- a/bin/addons/__init__.py
+++ b/bin/addons/__init__.py
@@ -131,9 +131,11 @@ def create_graph(module_list, force=[]):
packages = []
for module in module_list:
+ if module[-4:]=='.zip':
+ module = module[:-4]
terp_file = opj(ad, module, '__terp__.py')
mod_path = opj(ad, module)
- if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path):
+ if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'):
info = eval(tools.file_open(terp_file).read())
if info.get('installable', True):
packages.append((module, info.get('depends', []), info))
@@ -191,6 +193,7 @@ def load_module_graph(cr, graph, status={}):
for filename in package.datas.get('%s_xml' % kind, []):
mode = 'update'
if hasattr(package, 'init') or package_state=='to install':
+ print 'Mode', mode, filename
mode = 'init'
logger.notifyChannel('init', netsvc.LOG_INFO, 'addon:%s:loading %s' % (m, filename))
name, ext = os.path.splitext(filename)
@@ -235,7 +238,7 @@ def register_classes():
imp.load_module(m, *imp.find_module(m))
except ImportError:
import zipimport
- mod_path = opj(ad, m)
+ mod_path = opj(ad, m+'.zip')
zimp = zipimport.zipimporter(mod_path)
zimp.load_module(m)
diff --git a/bin/addons/base/module/module_wizard.xml b/bin/addons/base/module/module_wizard.xml
index df0ebc2c2bd..967d9c990a9 100644
--- a/bin/addons/base/module/module_wizard.xml
+++ b/bin/addons/base/module/module_wizard.xml
@@ -9,15 +9,21 @@
name="module.info_get"/>
-->
+ name="base.module.export"
+ id="wizard_base_module_export"/>
+
+
+ id="menu_wizard_module_import"/>
Download module list
diff --git a/bin/addons/base/module/wizard/__init__.py b/bin/addons/base/module/wizard/__init__.py
index ecf160f51f7..4e36b2d57d3 100644
--- a/bin/addons/base/module/wizard/__init__.py
+++ b/bin/addons/base/module/wizard/__init__.py
@@ -33,4 +33,5 @@ import wizard_module_lang_install
import add_new
import wizard_export_lang
import wizard_import_lang
-import move_module_wizard
+import wizard_module_export
+import wizard_module_import
diff --git a/bin/addons/base/module/wizard/move_module_wizard.py b/bin/addons/base/module/wizard/wizard_module_export.py
similarity index 98%
rename from bin/addons/base/module/wizard/move_module_wizard.py
rename to bin/addons/base/module/wizard/wizard_module_export.py
index 446dafe5445..d93fb5082b5 100644
--- a/bin/addons/base/module/wizard/move_module_wizard.py
+++ b/bin/addons/base/module/wizard/wizard_module_export.py
@@ -95,4 +95,4 @@ class move_module_wizard(wizard.interface):
}
}
}
-move_module_wizard('tmp.wizard')
+move_module_wizard('base.module.export')
diff --git a/bin/addons/base/module/wizard/wizard_module_import.py b/bin/addons/base/module/wizard/wizard_module_import.py
new file mode 100644
index 00000000000..0731de4030c
--- /dev/null
+++ b/bin/addons/base/module/wizard/wizard_module_import.py
@@ -0,0 +1,103 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# 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 osv
+import pooler
+import os
+import tools
+
+import zipfile
+import StringIO
+import base64
+
+finish_form ='''
+
+'''
+
+ask_form ='''
+
+'''
+
+ask_fields = {
+ 'module_file': {'string': 'Module .ZIP file', 'type':'binary'},
+}
+
+class move_module_wizard(wizard.interface):
+ def importzip(self, cr, uid, data, context):
+ module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
+ module_data = data['form']['module_file']
+
+ val =base64.decodestring(module_data)
+ fp = StringIO.StringIO(val)
+ fdata = zipfile.ZipFile(fp, 'r')
+ fname = fdata.namelist()[0]
+ module_name = os.path.split(fname)[0]
+
+ ad = tools.config['addons_path']
+
+ if os.path.isdir(os.path.join(ad,module_name)) or os.path.isfile(os.path.join(ad,module_name+'.zip')):
+ raise wizard.except_wizard('Error !', 'This module already exist in your system !')
+
+ fname = os.path.join(ad,module_name+'.zip')
+ try:
+ fp = file(fname, 'wb')
+ fp.write(val)
+ fp.close()
+ except IOError, e:
+ raise wizard.except_wizard('Error !', 'Can not create the module file:\n'+' '+fname+'!')
+
+ return {}
+
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {
+ 'type':'form',
+ 'arch':ask_form,
+ 'fields':ask_fields,
+ 'state':[('end','Cancel'),('import','Import module')]
+ }
+ },
+ 'import': {
+ 'actions': [importzip],
+ 'result': {
+ 'type':'form',
+ 'arch':finish_form,
+ 'fields':{},
+ 'state':[('end','Close')]
+ }
+ }
+ }
+move_module_wizard('base.module.import')
diff --git a/bin/tools/misc.py b/bin/tools/misc.py
index 597c203e81a..53cf1ce883d 100644
--- a/bin/tools/misc.py
+++ b/bin/tools/misc.py
@@ -67,6 +67,7 @@ def init_db(cr):
elif zipfile.is_zipfile(mod_path):
zfile = zipfile.ZipFile(mod_path)
i = os.path.splitext(i)[0]
+ print i
info = eval(zfile.read(opj(i, '__terp__.py')))
if info:
categs = info.get('category', 'Uncategorized').split('/')
@@ -179,11 +180,11 @@ def file_open(name, mode="r", subdir='addons'):
name = os.path.join(tail, name)
else:
name = tail
- if zipfile.is_zipfile(head):
+ if zipfile.is_zipfile(head+'.zip'):
import StringIO
- zfile = zipfile.ZipFile(head)
+ zfile = zipfile.ZipFile(head+'.zip')
return StringIO.StringIO(zfile.read(os.path.join(os.path.basename(head), name)))
- raise IOError, 'File not found : '+str(name)
+ raise IOError, 'File not found : '+str(name)
#----------------------------------------------------------