<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Python_magic</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>__ac_local_roles__</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string>def getModuleActionInformationDict(**kw):\n
  N_ = context.Base_translateString\n
  result_dict = {}\n
\n
  # If the user is not allowed to get the category, return immediately.\n
  portal = context.getPortalObject()\n
  business_application = portal.restrictedTraverse(\'portal_categories/business_application\',\n
                                                   None)\n
  if business_application is None:\n
    return result_dict\n
\n
  renderCustomLink = portal.ERP5Site_renderCustomLink\n
  listFilteredActionsFor = portal.portal_actions.listFilteredActionsFor\n
  cancel_url = portal.absolute_url()\n
\n
  # Use searchFolder, because security checks are required, and sorting\n
  # is not supported by listFolderContents.\n
  for o in business_application.searchFolder(sort_on=\'int_index\'):\n
    module_category = o.getObject()\n
    module_list = module_category.getBusinessApplicationRelatedValueList(\n
                    checked_permission=\'View\',\n
                    portal_type=portal.getPortalModuleTypeList())\n
\n
    # It is necessary to sort the modules by translated titles for convenience.\n
    titled_module_list = [(module.getTranslatedTitle(), module) for module in module_list]\n
    titled_module_list.sort(lambda a,b: cmp(a[0], b[0]))\n
\n
    view_list = []\n
    add_list = []\n
    search_list = []\n
    exchange_list = []\n
    report_list = []\n
    print_list = []\n
\n
    for translated_title, module in titled_module_list:\n
      module_url = module.absolute_url()\n
      action_dict = module.Base_filterDuplicateActions(listFilteredActionsFor(module))\n
\n
      # Obtain a form id and a selection name from the view.\n
      form_id = \'view\'\n
      selection_name = \'default_selection\'\n
      type_info = module.getTypeInfo()\n
      expr = None\n
      for ai in type_info.listActions():\n
        if ai.getId() == \'view\':\n
          break\n
      else:\n
        ai = None\n
      if ai is not None:\n
        form_id = str(ai.getActionExpression()).rsplit(\'/\', 1)[-1]\n
        form = getattr(portal, form_id, None)\n
        if form is not None:\n
          listbox = form.Form_getListbox()\n
          if listbox is not None:\n
            selection_name = listbox.get_value(\'selection_name\')\n
\n
      # Collect view actions.\n
      module_view_list = [(None, \'%s/view\' % module_url)]\n
      view_list.append((translated_title, module_view_list))\n
\n
      # Collect add actions.\n
      module_add_list = []\n
      for content_type in module.getVisibleAllowedContentTypeList():\n
        action = \'add %s\' % content_type\n
        url = renderCustomLink(\'%s/Base_doAction\' % module_url,\n
                               dict(cancel_url=cancel_url,\n
                                    form_id=form_id,\n
                                    selection_name=selection_name,\n
                                    select_action=action))\n
        module_add_list.append((content_type, url))\n
      for template in module.getDocumentTemplateList():\n
        action = \'template %s\' % template.getRelativeUrl()\n
        url = renderCustomLink(\'%s/Base_doAction\' % module_url,\n
                               dict(cancel_url=cancel_url,\n
                                    form_id=form_id,\n
                                    selection_name=selection_name,\n
                                    select_action=action))\n
        template_name = N_(\'${template_title} (Template)\',\n
                           mapping=dict(template_title=template.getTitle()))\n
        module_add_list.append((template_name, url))\n
      for add_action in action_dict.get(\'object_add\', ()):\n
        url = renderCustomLink(add_action[\'url\'],\n
                               dict(cancel_url=cancel_url,\n
                                    form_id=form_id,\n
                                    selection_name=selection_name,\n
                                    select_action=action))\n
        module_add_list.append((add_action[\'name\'], url))\n
      if module_add_list:\n
        add_list.append((translated_title, module_add_list))\n
\n
      # Collect search actions.\n
      module_search_list = []\n
      for search_action in action_dict.get(\'object_search\', ()):\n
        url = renderCustomLink(search_action[\'url\'],\n
                               dict(cancel_url=cancel_url,\n
                                    form_id=form_id,\n
                                    selection_name=selection_name,\n
                                    dialog_category=\'object_search\')).strip()\n
        module_search_list.append((search_action[\'name\'], url))\n
      if module_search_list:\n
        search_list.append((translated_title, module_search_list))\n
\n
      # Collect exchange actions.\n
      module_exchange_list = []\n
      for exchange_action in action_dict.get(\'object_exchange\', ()):\n
        url = renderCustomLink(exchange_action[\'url\'],\n
                               dict(cancel_url=cancel_url,\n
                                    form_id=form_id,\n
                                    selection_name=selection_name,\n
                                    dialog_category=\'object_exchange\')).strip()\n
        module_exchange_list.append((exchange_action[\'name\'], url))\n
      if module_exchange_list:\n
        exchange_list.append((translated_title, module_exchange_list))\n
\n
      # Collect report actions.\n
      module_report_list = []\n
      for report_action in action_dict.get(\'object_report\', ()):\n
        url = renderCustomLink(report_action[\'url\'],\n
                               dict(cancel_url=cancel_url,\n
                                    form_id=form_id,\n
                                    selection_name=selection_name,\n
                                    dialog_category=\'object_report\')).strip()\n
        module_report_list.append((report_action[\'name\'], url))\n
      if module_report_list:\n
        report_list.append((translated_title, module_report_list))\n
\n
      # Collect print actions.\n
      module_print_list = []\n
      for print_action in action_dict.get(\'object_print\', ()):\n
        url = renderCustomLink(print_action[\'url\'],\n
                               dict(cancel_url=cancel_url,\n
                                    form_id=form_id,\n
                                    selection_name=selection_name,\n
                                    dialog_category=\'object_print\')).strip()\n
        module_print_list.append((print_action[\'name\'], url))\n
      if module_print_list:\n
        print_list.append((translated_title, module_print_list))\n
\n
    # Add the actions, only if they are not empty.\n
    action_list_dict = {}\n
    for k, v in ((\'add\', add_list), (\'search\', search_list),\n
                 (\'exchange\', exchange_list), (\'report\', report_list),\n
                 (\'print\', print_list), (\'view\', view_list)):\n
      if v:\n
        result_dict.setdefault(k, []).append((module_category.getTitle(), v))\n
\n
  return result_dict\n
\n
from Products.ERP5Type.Cache import CachingMethod\n
from AccessControl import getSecurityManager\n
\n
getModuleActionInformationDict = CachingMethod(getModuleActionInformationDict,\n
                                               id=\'ERP5Site_getModuleActionInformationDict\',\n
                                               cache_factory=\'erp5_ui_long\')\n
return getModuleActionInformationDict(user=getSecurityManager().getUser(),\n
                                      language=context.Localizer.get_selected_language())\n
</string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_filepath</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_owner</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>errors</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
        <item>
            <key> <string>func_code</string> </key>
            <value>
              <object>
                <klass>
                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>co_argcount</string> </key>
                        <value> <int>0</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>getModuleActionInformationDict</string>
                            <string>Products.ERP5Type.Cache</string>
                            <string>CachingMethod</string>
                            <string>AccessControl</string>
                            <string>getSecurityManager</string>
                            <string>_getattr_</string>
                            <string>context</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>ERP5Site_getCategorizedModuleActionInformationDict</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
