diff --git a/addons/portal/ir_ui_menu.py b/addons/portal/ir_ui_menu.py index f9c5fbf3f35..7326a12122b 100644 --- a/addons/portal/ir_ui_menu.py +++ b/addons/portal/ir_ui_menu.py @@ -33,7 +33,7 @@ class portal_menu(osv.osv): # if the current user belongs to a portal, we have to # rewrite any search on the top menus to be under the # portal's root menu: - if not context.get('ir.ui.menu.full_list') and \ + if not context.get('ir.ui.menu.full_list') and uid != 1 and \ args and len(args) == 1 and \ len(args[0]) == 3 and \ (args[0][0] == 'parent_id' \ diff --git a/addons/portal/wizard/share_wizard.py b/addons/portal/wizard/share_wizard.py index 1ed28f4d692..d05cf49d9fa 100644 --- a/addons/portal/wizard/share_wizard.py +++ b/addons/portal/wizard/share_wizard.py @@ -22,35 +22,44 @@ from osv import osv UID_ROOT = 1 -SHARED_DOCS_MENU = "Shared Documents" +SHARED_DOCS_MENU = "Documents" +SHARED_DOCS_CHILD_MENU = "Shared Documents" class share_wizard_portal(osv.osv_memory): """Inherited share wizard to automatically create appropriate menus in the selected portal upon sharing with a portal group.""" _inherit = "share.wizard" + def _create_or_get_submenu_named(self, cr, uid, parent_menu_id, menu_name, context=None): + if not parent_menu_id: + return + Menus = self.pool.get('ir.ui.menu') + parent_menu = Menus.browse(cr, uid, parent_menu_id) # No context + menu_id = None + max_seq = 10 + for child_menu in parent_menu.child_id: + max_seq = max(max_seq, child_menu.sequence) + if child_menu.name == menu_name: + menu_id = child_menu.id + break + if not menu_id: + # not found, create it + menu_id = Menus.create(cr, UID_ROOT, + {'name': menu_name, + 'parent_id': parent_menu.id, + 'sequence': max_seq + 10, # at the bottom + }) + return menu_id + def _sharing_root_menu_id(self, cr, uid, portal, context=None): """Create or retrieve root ID of sharing menu in portal menu :param portal: browse_record of portal, constructed with a context WITHOUT language """ - if not portal.parent_menu_id: - # no specific parent menu, cannot create the sharing menu at all. - return - # look for an existing SHARED_DOCS_MENU - sharing_root_menu_id = None - for child_menu in portal.parent_menu_id.child_id: - if child_menu.name == SHARED_DOCS_MENU: - sharing_root_menu_id = child_menu.id - break - if not sharing_root_menu_id: - # not found, create it - sharing_root_menu_id = self.pool.get('ir.ui.menu').create(cr, UID_ROOT, - {'name': SHARED_DOCS_MENU, - 'parent_id': portal.parent_menu_id.id, - 'sequence': 999, # at the bottom - }) - return sharing_root_menu + parent_menu_id = self._create_or_get_submenu_named(cr, uid, portal.parent_menu_id.id, SHARED_DOCS_MENU, context=context) + if parent_menu_id: + child_menu_id = self._create_or_get_submenu_named(cr, uid, parent_menu_id, SHARED_DOCS_CHILD_MENU, context=context) + return child_menu_id def _create_shared_data_menu(self, cr, uid, wizard_data, portal, context=None): """Create sharing menus in portal menu according to share wizard options.