<?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[

isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible\n
if context.getSimulationState() == \'planned\' and context.getStartDate() < this_month:\n
  if len(context.getMovementList()) > 0:\n
    if isTransitionPossible(context, \'confirm\'):\n
      context.confirm(comment=\'Confirmed as ready to be accounted.\')\n
      # as user will not have any invoice in planned state create new one, a bit later, in order to have current state reindexed\n
      context.getDestinationValue().activate(after_path_and_method_id=(context.getPath(), (\'recursiveImmediateReindexObject\', \'immediateReindexObject\'))).fixConsistency()\n
  else:\n
    old_date = context.getStartDate()\n
    context.setStartDate(this_month)\n
    context.portal_workflow.doActionFor(context, \'edit_action\', comment=\'Moved date from %s to %s in order to move to new month.\' % (old_date, context.getStartDate()))\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>this_month</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>SaleInvoiceTransaction_confirmPlanned</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
