[Fix] Bug 335778 : Corrected get_module_path method to work for non-local module
authorJay (Open ERP) <jvo@tinyerp.com>
Mon, 2 Mar 2009 13:31:40 +0000 (19:01 +0530)
committerJay (Open ERP) <jvo@tinyerp.com>
Mon, 2 Mar 2009 13:31:40 +0000 (19:01 +0530)
bzr revid: jvo@tinyerp.com-20090302133140-czmt1cmpnxxukbss

bin/addons/__init__.py
bin/addons/base/module/module.py

index 414fe21..47634d8 100644 (file)
@@ -139,15 +139,15 @@ class Node(Singleton):
         return s
 
 
-def get_module_path(module):
+def get_module_path(module, downloaded=False):
     """Return the path of the given module."""
-
     if os.path.exists(opj(ad, module)) or os.path.exists(opj(ad, '%s.zip' % module)):
         return opj(ad, module)
 
     if os.path.exists(opj(_ad, module)) or os.path.exists(opj(_ad, '%s.zip' % module)):
         return opj(_ad, module)
-
+    if downloaded:
+        return opj(_ad, module)
     logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: module not found' % (module,))
     return False
 
index e5e7641..7867afa 100644 (file)
@@ -398,12 +398,12 @@ class module(osv.osv):
             if not download:
                 continue
             zipfile = urllib.urlopen(mod.url).read()
-            fname = addons.get_module_path(mod.name+'.zip')
+            fname = addons.get_module_path(str(mod.name)+'.zip', downloaded=True)
             try:
                 fp = file(fname, 'wb')
                 fp.write(zipfile)
                 fp.close()
-            except IOError, e:
+            except Exception, e:
                 raise orm.except_orm(_('Error'), _('Can not create the module file:\n %s') % (fname,))
             terp = self.get_module_info(mod.name)
             self.write(cr, uid, mod.id, {