<?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>"""This script is called on the Invoice after the delivery builder has created\n
the new Invoice.\n
"""\n
from Products.ERP5Type.Message import translateString\n
from DateTime import DateTime\n
if related_simulation_movement_path_list is None:\n
  raise RuntimeError, \'related_simulation_movement_path_list is missing. Update ERP5 Product.\'\n
\n
invoice = context\n
\n
# if installed erp5_simplified_invoicing, set resource from price currency\n
#if not invoice.Invoice_isAdvanced():\n
if 1:\n
  if not invoice.getResource():\n
    invoice.setResource(invoice.getPriceCurrency())\n
\n
if invoice.getStartDate() is None:\n
  invoice.setStartDate(DateTime())\n
\n
tag = \'%s_plan\' % invoice.getPath()\n
# initialize accounting_workflow to planned state\n
if invoice.getSimulationState() == \'draft\':\n
  invoice.plan(comment=translateString(\'Initialised by Delivery Builder.\'), activate_kw={\'tag\': tag})\n
\n
# update specialise from movements\n
specialise_list = invoice.getSpecialiseList()\n
specialise_list.sort()\n
\n
modified = 0\n
for movement in invoice.getMovementList(portal_type=\'Invoice Line\'):\n
  movement_specialise = movement.getSpecialise()\n
  if movement_specialise not in specialise_list:\n
    modified = 1\n
    specialise_list.append(movement_specialise)\n
\n
if modified:\n
  specialise_list.sort()\n
  invoice.setSpecialiseList(specialise_list)\n
\n
if invoice.getPortalObject().portal_workflow.isTransitionPossible(invoice, \'start_building\'):\n
  invoice.startBuilding()\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>related_simulation_movement_path_list=None, **kw</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>VifibInvoiceTransaction_postGeneration</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
