<?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 encoding="cdata"><![CDATA[

portal = context.getPortalObject()\n
\n
activate_kw = {\n
  \'tag\': tag\n
}\n
simulation_state_list = portal.getPortalCurrentInventoryStateList() + \\\n
  portal.getPortalTransitInventoryStateList() + portal.getPortalPlannedOrderStateList() + \\\n
  portal.getPortalReservedInventoryStateList() + portal.getPortalFutureInventoryStateList()\n
kw = dict(\n
  portal_type_list=[\'Sale Packing List Line\', \'Invoice Line\', \'Accounting Transaction Line\', \'Sale Invoice Transaction Line\'],\n
  simulation_state_list=simulation_state_list,\n
  base_category_uid=portal.portal_categories.delivery.getUid()\n
)\n
path_list = set()\n
\n
for q in portal.Base_getNotCategoryRelatedList(**kw):\n
  path_list.add(q.getPath())\n
\n
for q in portal.Base_getNotSynchronisedSimulationStateCategoryRelatedList(**kw):\n
  path_list.add(q.getPath())\n
\n
# and all invoice lines and and transcation lines in confirmed state\n
# XXX: We do simple version, and in Vifib confirmed ones can be often expanded, as it is short living state\n
\n
for q in portal.portal_catalog(portal_type=\'Invoice Line\', simulation_state=\'confirmed\'):\n
  if q.getSimulationState() == \'confirmed\':\n
    path_list.add(q.getPath())\n
path_list = list(path_list)\n
\n
if len(path_list) > 0:\n
  portal.portal_catalog.searchAndActivate(\n
    path=path_list,\n
    packet_size=1, # Separate calls to many transactions\n
    activate_kw=activate_kw,\n
    method_id=\'DeliveryLine_updateAppliedRule\',\n
    method_kw={\'activate_kw\': activate_kw, \'kw\': {\'activate_kw\': activate_kw}},\n
  )\n
\n
  # register activity on alarm object waiting for own tag in order to have only one alarm\n
  # running in same time\n
  context.activate(after_tag=tag).getId()\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>tag, fixit, params</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Alarm_expandDeliveryLine</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
