Commit d890b4b7 authored by Aurel's avatar Aurel

add generic script to treat check

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10820 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 30537c9c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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[
# This script will check if a given reference exist in all checks.\n
# If this reference does not exist yet, we will have two choices\n
# 1 - if a end date is not passed yet, we will create the check\n
# 2 - if the end date is passed, we raise an error\n
from Products.ERP5Type.Message import Message\n
from DateTime import DateTime\n
\n
\n
bank_account = context.getDestinationPaymentValue()\n
reference_list = [reference]\n
check_list = []\n
for check_reference in reference_list:\n
message_tag = \'check_%s\' % (check_reference, )\n
# just raise an error.\n
if context.portal_activities.countMessageWithTag(message_tag) != 0:\n
msg = Message(domain=\'ui\', message="This check number is already being indexed.")\n
raise ValidationFailed, (msg,)\n
result = context.portal_catalog(portal_type = \'Check\', reference = check_reference)\n
if len(result) == 0:\n
# We will not allow creation of generic check after a particular date\n
end_date = DateTime(\'2009/01/01\')\n
now = DateTime()\n
if (now - end_date) >0:\n
msg = Message(domain = "ui", message="Sorry, this reference does not exist")\n
raise ValidationFailed, (msg,)\n
\n
# This happens only if automatic creation is allowed. So create a new check at this point.\n
# Get a checkbook for this bank account.\n
checkbook = None\n
generic_model = context.portal_catalog(portal_type = \'Checkbook Model\', title = \'Generic\')[0].getObject()\n
# XXX it would be better to use a related key for this, but z_related_resource is too specific to\n
# movement at the moment.\n
for brain in context.portal_catalog(portal_type = \'Checkbook\',\n
destination_payment_uid = bank_account.getUid()):\n
obj = brain.getObject()\n
if obj.getResourceUid() == generic_model.getUid():\n
checkbook = obj\n
break\n
if checkbook is None:\n
# Create a checkbook.\n
# To prevent duplicated checkbooks for a single bank account, index this new checkbook immediately.\n
# This has a performance penalty, but this part of the script will rarely be called (once per bank account).\n
checkbook = context.checkbook_module.newContent(portal_type = \'Checkbook\',\n
resource_value = generic_model,\n
destination_payment_value = bank_account,\n
immediate_reindex = 1)\n
# Create a check.\n
check = checkbook.newContent(portal_type = \'Check\', reference = check_reference, activate_kw={\'tag\': message_tag})\n
# Automatically issue this check.\n
check.confirm()\n
else:\n
check = result[0].getObject()\n
check_list.append(check)\n
\n
if reference is not None:\n
return check\n
return check_list\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference=None, reference_range_min=None, reference_range_max=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>reference</string>
<string>reference_range_min</string>
<string>reference_range_max</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>DateTime</string>
<string>_getattr_</string>
<string>context</string>
<string>bank_account</string>
<string>reference_list</string>
<string>check_list</string>
<string>_getiter_</string>
<string>check_reference</string>
<string>message_tag</string>
<string>msg</string>
<string>ValidationFailed</string>
<string>result</string>
<string>len</string>
<string>end_date</string>
<string>now</string>
<string>None</string>
<string>checkbook</string>
<string>_getitem_</string>
<string>generic_model</string>
<string>brain</string>
<string>obj</string>
<string>check</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_checkOrCreateCheck</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment