<?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>from Products.ERP5Type.Errors import SimulationError\n
\n
delivery = context\n
delivery_type = context.getPortalType()\n
\n
# XXX The following dict is only for backward compatibility.\n
applied_rule_dict = {\n
  \'Pay Sheet Transaction\': \'default_invoice_rule\',\n
  \'Payment Transaction\': \'default_invoice_rule\',\n
\n
  \'Purchase Packing List\': \'default_delivery_rule\',\n
  \'Purchase Invoice Transaction\': \'default_invoice_rule\',\n
\n
  \'Sale Order\': \'default_order_rule\',\n
  \'Sale Packing List\': \'default_delivery_rule\',\n
# XXX-Romain: no need for root applied rule for sale invoice\n
#   \'Sale Invoice Transaction\': \'default_invoice_rule\',\n
  \'Sale Invoice Transaction\': None,\n
\n
  \'Internal Packing List\': None,\n
  \'Returned Sale Packing List\': None,\n
\n
  \'Accounting Rule Cell\': None,\n
  \'Accounting Transaction\': None,\n
  \'Production Packing List\': None,\n
  \'Production Report\': None,\n
  \'Pay Sheet Model\': None,\n
  \n
  \'Amortisation Transaction\' : None,\n
  \'Task Report\': \'default_delivery_rule\',\n
  }\n
\n
try:\n
  applied_rule = delivery.getRuleReference()\n
except SimulationError:\n
  marker = []\n
  applied_rule = applied_rule_dict.get(delivery_type, marker)\n
  if applied_rule is marker:\n
    raise\n
\n
if applied_rule is None:\n
  # No need to add a rule, but still we need to expand the delivery\n
  # if at least one of its movements is simulated.\n
  for m in delivery.getMovementList():\n
    if m.isSimulated():\n
      delivery.activate(activate_kw=activate_kw).expand(**kw)\n
      return\n
elif applied_rule:\n
  delivery.updateAppliedRule(rule_reference=applied_rule, activate_kw=activate_kw, **kw)\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>activate_kw=None, **kw</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Delivery_updateAppliedRule</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
