<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </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>"""Returns the item list of possible projects to use on accounting lines.\n
\n
This script is indented to be used on custom listfields for accounting lines, and on reports.\n
If this script returns an empty list, it means that reports by project are disabled.\n
"""\n
from Products.ERP5Type.Message import translateString\n
portal = context.getPortalObject()\n
request = portal.REQUEST\n
\n
# case 1: script is used for reports, we display all project that have been used in accounting.\n
if context.getPortalType() == \'Accounting Transaction Module\':\n
  getObject = portal.portal_catalog.getObject\n
  search_kw=dict(portal_type=portal.getPortalAccountingMovementTypeList(),\n
                 group_by=(\'stock.project_uid\',))\n
  section_category = request.get(\'your_section_category\',\n
       portal.portal_preferences.getPreferredAccountingTransactionSectionCategory())\n
  if section_category:\n
    section_uid = portal.Base_getSectionUidListForSectionCategory(\n
                               section_category=section_category,\n
                               strict_membership=request.get(\'your_section_category_strict\', False))\n
    search_kw[\'section_uid\'] = section_uid\n
\n
  project_list = []\n
  for brain in portal.portal_simulation.getInventoryList(**search_kw):\n
    if brain.project_uid:\n
      project = getObject(brain.project_uid)\n
      project_list.append((project.getTitle(), project.getRelativeUrl(),))\n
  project_list.sort(key=lambda x:x[0])\n
  if not project_list:\n
    return [] # returning an empty list, not to add project column on reports\n
  return [(\'\', \'\'), (translateString(\'No Project\'), \'None\')] + project_list\n
  \n
# case 2: script is used on custom listfields.\n
#  for now the script has to be customized in such case.\n
# [(x.getTitle(), x.getRelativeUrl()) for x in context.project_module.searchFolder()]\n
return [(\'\', \'\')]\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>source=True</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>AccountingTransactionLine_getProjectItemList</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
