Antony Lesuisse (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-server/trunk-immediate-install-al into 
lp:openobject-server.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-immediate-install-al/+merge/85310

immediate install, remove old web
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-immediate-install-al/+merge/85310
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-immediate-install-al.
=== modified file 'openerp/addons/base/module/module.py'
--- openerp/addons/base/module/module.py	2011-12-09 16:58:06 +0000
+++ openerp/addons/base/module/module.py	2011-12-12 10:44:25 +0000
@@ -40,7 +40,6 @@
 
 from osv import fields, osv, orm
 
-
 ACTION_DICT = {
     'view_type': 'form',
     'view_mode': 'form',
@@ -214,7 +213,6 @@
         'reports_by_module': fields.function(_get_views, method=True, string='Reports', type='text', multi="meta", store=True),
         'views_by_module': fields.function(_get_views, method=True, string='Views', type='text', multi="meta", store=True),
         'certificate' : fields.char('Quality Certificate', size=64, readonly=True),
-        'web': fields.boolean('Has a web component', readonly=True),
         'application': fields.boolean('Application', readonly=True),
         'icon': fields.char('Icon URL', size=128),
         'complexity': fields.selection([('easy','Easy'), ('normal','Normal'), ('expert','Expert')],
@@ -226,7 +224,6 @@
         'state': 'uninstalled',
         'demo': False,
         'license': 'AGPL-3',
-        'web': False,
         'complexity': 'normal',
     }
     _order = 'name'
@@ -333,7 +330,16 @@
         self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
         cr.commit()
         db, pool = pooler.restart_pool(cr.dbname, update_module=True)
-        return pool.get('res.config').next(db.cursor(), uid, [], context=context)
+        menu_ids = self.root_menus(cr,uid,ids,context)
+        print "Menus, Menus:",menu_ids
+        if menu_ids:
+            action = {
+                'type': 'ir.ui.menu',
+                'menu_id': menu_ids[0],
+                'reload' : True,
+            }
+            return action
+        return False
 
     def button_install_cancel(self, cr, uid, ids, context=None):
         self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})
@@ -411,7 +417,6 @@
             'website': terp.get('website', ''),
             'license': terp.get('license', 'AGPL-3'),
             'certificate': terp.get('certificate') or False,
-            'web': terp.get('web') or False,
             'complexity': terp.get('complexity', ''),
         }
 
@@ -584,31 +589,6 @@
                     logger.critical('module %s: invalid quality certificate: %s', mod.name, mod.certificate)
                     raise osv.except_osv(_('Error'), _('Module %s: Invalid Quality Certificate') % (mod.name,))
 
-    def list_web(self, cr, uid, context=None):
-        """ list_web(cr, uid, context) -> [(module_name, module_version)]
-        Lists all the currently installed modules with a web component.
-
-        Returns a list of a tuple of addon names and addon versions.
-        """
-        return [
-            (module['name'], module['installed_version'])
-            for module in self.browse(cr, uid,
-                self.search(cr, uid,
-                    [('web', '=', True),
-                     ('state', 'in', ['installed','to upgrade','to remove'])],
-                    context=context),
-                context=context)]
-    def _web_dependencies(self, cr, uid, module, context=None):
-        for dependency in module.dependencies_id:
-            (parent,) = self.browse(cr, uid, self.search(cr, uid,
-                [('name', '=', dependency.name)], context=context),
-                                 context=context)
-            if parent.web:
-                yield parent.name
-            else:
-                self._web_dependencies(
-                    cr, uid, parent, context=context)
-
     def _translations_subdir(self, module):
         """ Returns the path to the subdirectory holding translations for the
         module files, or None if it can't find one
@@ -623,106 +603,26 @@
         if subdir: return subdir
         return None
 
-    def _add_translations(self, module, web_data):
-        """ Adds translation data to a zipped web module
-
-        :param module: a module descriptor
-        :type module: browse(ir.module.module)
-        :param web_data: zipped data of a web module
-        :type web_data: bytes
-        """
-        # cStringIO.StringIO is either read or write, not r/w
-        web_zip = StringIO.StringIO(web_data)
-        web_archive = zipfile.ZipFile(web_zip, 'a')
-
-        # get the contents of the i18n or po folder and move them to the
-        # po/messages subdirectory of the web module.
-        # The POT file will be incorrectly named, but that should not
-        # matter since the web client is not going to use it, only the PO
-        # files.
-        translations_file = cStringIO.StringIO(
-            addons.zip_directory(self._translations_subdir(module), False))
-        translations_archive = zipfile.ZipFile(translations_file)
-
-        for path in translations_archive.namelist():
-            web_path = os.path.join(
-                'web', 'po', 'messages', os.path.basename(path))
-            web_archive.writestr(
-                web_path,
-                translations_archive.read(path))
-
-        translations_archive.close()
-        translations_file.close()
-
-        web_archive.close()
-        try:
-            return web_zip.getvalue()
-        finally:
-            web_zip.close()
-
-    def get_web(self, cr, uid, names, context=None):
-        """ get_web(cr, uid, [module_name], context) -> [{name, depends, content}]
-
-        Returns the web content of all the named addons.
-
-        The toplevel directory of the zipped content is called 'web',
-        its final naming has to be managed by the client
-        """
-        modules = self.browse(cr, uid,
-            self.search(cr, uid, [('name', 'in', names)], context=context),
-                              context=context)
-        if not modules: return []
-        self.__logger.info('Sending web content of modules %s '
-                           'to web client', names)
-
-        modules_data = []
-        for module in modules:
-            web_data = addons.zip_directory(
-                addons.get_module_resource(module.name, 'web'), False)
-            if self._translations_subdir(module):
-                web_data = self._add_translations(module, web_data)
-            modules_data.append({
-                'name': module.name,
-                'version': module.installed_version,
-                'depends': list(self._web_dependencies(
-                    cr, uid, module, context=context)),
-                'content': base64.encodestring(web_data)
-            })
-        return modules_data
-
-    def menus(self, cr, uid, ids, maxdepth=0, context=None):
-        """ Returns ids of all menus of depth below ``maxdepth``
-        created by the modules whose ids are provided.
+    def root_menus(self, cr, uid, ids, context=None):
+        """ Return root menu ids the menus created by the modules whose ids are
+        provided.
 
         :param list[int] ids: modules to get menus from
-        :param list[str] fields: list of menu fields to fetch, defaults to all
-        :param int maxdepth: maximum depth of menus to return, returns all menus by default
-        :returns: a list of menu object dicts
-        :rtype: list[int]
         """
-        IrModelData = self.pool.get('ir.model.data')
-        menus = []
-        module_names = [module.name for module in self.browse(cr, uid, ids, context=context)]
-
-        all_menu_ids = [model.res_id for model in IrModelData.browse(cr, uid,
-                        IrModelData.search(cr, uid, [
-                            ('model', '=', 'ir.ui.menu'), ('module', 'in', module_names)
-                        ], context=context),
-                    context=context)]
-
-        for candidate in self.pool.get('ir.ui.menu').browse(cr, uid, all_menu_ids, context=context):
-            if not maxdepth:
-                menus.append(candidate.id)
-                continue
-            depth = 1
-            menu = candidate
+        values = self.read(cr, uid, ids, ['name'], context=context)
+        module_names = [i['name'] for i in values]
+
+        ids = self.pool.get('ir.model.data').search(cr, uid, [ ('model', '=', 'ir.ui.menu'), ('module', 'in', module_names) ], context=context)
+        values = self.pool.get('ir.model.data').read(cr, uid, ids, ['res_id'], context=context)
+        all_menu_ids = [i['res_id'] for i in values]
+
+        root_menu_ids = []
+        for menu in self.pool.get('ir.ui.menu').browse(cr, uid, all_menu_ids, context=context):
             while menu.parent_id:
-                depth += 1
                 menu = menu.parent_id
-            if depth <= maxdepth:
-                menus.append(candidate.id)
-        return menus
-module()
+            if not menu.id in root_menu_ids:
+                root_menu_ids.append(menu.id)
+        return root_menu_ids
 
 class module_dependency(osv.osv):
     _name = "ir.module.module.dependency"
@@ -752,6 +652,5 @@
             ('unknown', 'Unknown'),
             ], string='State', readonly=True, select=True),
     }
-module_dependency()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to