[FIX] modules: install_from_urls: restrict to administrators. Urls must come from...
authorChristophe Simonis <chs@openerp.com>
Thu, 10 Apr 2014 09:58:17 +0000 (11:58 +0200)
committerChristophe Simonis <chs@openerp.com>
Thu, 10 Apr 2014 09:58:17 +0000 (11:58 +0200)
[FIX] modules: download() method is now a no-op. This method was in fact already a no-op as the "url" field is never set explicitly in the code.

bzr revid: chs@openerp.com-20140410095817-bkni63g346wneybb

1  2 
openerp/addons/base/module/module.py
openerp/addons/base/static/src/js/apps.js

@@@ -619,40 -623,45 +621,14 @@@ class module(osv.osv)
          return res
  
      def download(self, cr, uid, ids, download=True, context=None):
--        res = []
--        default_version = modules.adapt_version('1.0')
--        for mod in self.browse(cr, uid, ids, context=context):
--            if not mod.url:
--                continue
--            match = re.search('-([a-zA-Z0-9\._-]+)(\.zip)', mod.url, re.I)
--            version = default_version
--            if match:
--                version = match.group(1)
--            if parse_version(mod.installed_version) >= parse_version(version):
--                continue
--            res.append(mod.url)
--            if not download:
--                continue
--            zip_content = urllib.urlopen(mod.url).read()
--            fname = modules.get_module_path(str(mod.name) + '.zip', downloaded=True)
--            try:
--                with open(fname, 'wb') as fp:
--                    fp.write(zip_content)
--            except Exception:
--                _logger.exception('Error when trying to create module '
--                                  'file %s', fname)
--                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, self.get_values_from_terp(terp))
--            cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s', (mod.id,))
--            self._update_dependencies(cr, uid, mod, terp.get('depends', []))
--            self._update_category(cr, uid, mod, terp.get('category', 'Uncategorized'))
--            # Import module
--            zimp = zipimport.zipimporter(fname)
--            zimp.load_module(mod.name)
--        return res
++        return []
  
      def install_from_urls(self, cr, uid, urls, context=None):
+         if not self.pool['res.users'].has_group(cr, uid, 'base.group_system'):
+             raise openerp.exceptions.AccessDenied()
+         apps_server = urlparse.urlparse(self.get_apps_server(cr, uid, context=context))
          OPENERP = 'openerp'
          tmp = tempfile.mkdtemp()
          _logger.debug('Install from url: %r', urls)