Commit b8a16533 authored by Sebastien Robin's avatar Sebastien Robin

make the reference of checks unique per account/type of check

also modified a bit the workflow of checkbook vault transfer

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14552 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5041f302
......@@ -71,7 +71,9 @@ from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n
# Check that a check exists for given bank account and reference.\n
result = context.Base_checkOrCreateCheck(reference=reference, bank_account=bank_account)\n
result = context.Base_checkOrCreateCheck(reference=reference, \n
bank_account=bank_account,\n
resource=resource)\n
result_len = len(result)\n
if result_len == 0:\n
msg = Message(domain=\'ui\', message="No such check")\n
......@@ -120,7 +122,7 @@ return check\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bank_account, reference</string> </value>
<value> <string>bank_account, reference, resource</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -140,7 +142,7 @@ return check\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -148,6 +150,7 @@ return check\n
<tuple>
<string>bank_account</string>
<string>reference</string>
<string>resource</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>Products.DCWorkflow.DCWorkflow</string>
......
......@@ -74,6 +74,8 @@
from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n
portal = context.getPortalObject()\n
\n
if bank_account is None:\n
if destination:\n
bank_account = context.getDestinationPaymentValue()\n
......@@ -84,6 +86,10 @@ if bank_account is None:\n
msg = Message(domain=\'ui\',message=\'Sorry, you must select an account\')\n
raise ValidationFailed, (msg,)\n
\n
if resource is None:\n
msg = Message(domain=\'ui\',message=\'Sorry, you must select a resource\')\n
raise ValidationFailed, (msg,)\n
\n
if reference is not None:\n
reference_list = [reference]\n
\n
......@@ -112,13 +118,18 @@ elif reference_range_min is not None or reference_range_max is not None:\n
reference_list.append(ref)\n
\n
check_list = []\n
bank_account_uid = bank_account.getUid()\n
resource_value = None\n
generic_model = None\n
for check_reference in reference_list:\n
message_tag = \'check_%s\' % (check_reference, )\n
message_tag = \'check_%s_%s_%s\' % (resource, bank_account_uid, 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, destination_payment_uid = bank_account.getUid())\n
result = context.portal_catalog(portal_type = \'Check\', reference = check_reference, \n
destination_payment_uid = bank_account.getUid(),\n
default_resource_relative_url = resource)\n
if len(result) == 0:\n
if not context.Base_isAutomaticCheckCreationAllowed():\n
msg = Message(domain = "ui", message="Sorry, this reference does not exist")\n
......@@ -127,23 +138,41 @@ for check_reference in reference_list:\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
if resource_value is None:\n
resource_value = portal.restristedTraverse(resource)\n
composition_related_list = resource_value.getCompositionRelatedValueList()\n
if len(composition_related_list) == 0:\n
msg = Message(domain = "ui", message="Sorry, no checkbook model found")\n
raise ValidationFailed, (msg,)\n
if len(composition_related_list) != 1:\n
msg = Message(domain = "ui", message="Sorry, too many many checkbook model found")\n
raise ValidationFailed, (msg,)\n
generic_model = composition_related_list[0]\n
\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
title = \'Generic\',\n
destination_payment_uid = bank_account.getUid(),\n
default_resource_uid = generic_model.getUid()):\n
obj = brain.getObject()\n
if obj.getResourceUid() == generic_model.getUid():\n
checkbook = obj\n
break\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_tag = "checkbook_%s_%s" % (resource, bank_account_uid) \n
if context.portal_activities.countMessageWithTag(checkbook_tag) != 0:\n
msg = Message(domain=\'ui\', message="There is already a checkbook being indexed.")\n
raise ValidationFailed, (msg,)\n
checkbook = context.checkbook_module.newContent(portal_type = \'Checkbook\',\n
title = \'Generic\',\n
resource_value = generic_model,\n
destination_payment_value = bank_account,\n
immediate_reindex = 1)\n
activate_kw={\'tag\' : checkbook_tag} )\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
......@@ -179,7 +208,7 @@ return check_list\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference=None, reference_range_min=None, reference_range_max=None, source=0, destination=1, bank_account=None</string> </value>
<value> <string>reference=None, reference_range_min=None, reference_range_max=None, source=0, destination=1, bank_account=None, resource=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -199,7 +228,7 @@ return check_list\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>6</int> </value>
<value> <int>7</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -211,13 +240,15 @@ return check_list\n
<string>source</string>
<string>destination</string>
<string>bank_account</string>
<string>resource</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>None</string>
<string>msg</string>
<string>reference_list</string>
<string>int</string>
......@@ -226,15 +257,19 @@ return check_list\n
<string>range</string>
<string>ref</string>
<string>check_list</string>
<string>bank_account_uid</string>
<string>resource_value</string>
<string>generic_model</string>
<string>check_reference</string>
<string>message_tag</string>
<string>result</string>
<string>len</string>
<string>checkbook</string>
<string>composition_related_list</string>
<string>_getitem_</string>
<string>generic_model</string>
<string>brain</string>
<string>obj</string>
<string>checkbook_tag</string>
<string>check</string>
</tuple>
</value>
......@@ -254,6 +289,7 @@ return check_list\n
<int>0</int>
<int>1</int>
<none/>
<none/>
</tuple>
</value>
</item>
......
......@@ -137,7 +137,7 @@ for line in context.getMovementList():\n
<string>$append0</string>
<string>_getiter_</string>
<string>_getattr_</string>
<string>context</string>
<string>context</string>
<string>x</string>
<string>current_tracking_list</string>
<string>aggregate_uid_list</string>
......
......@@ -434,7 +434,7 @@
</item>
<item>
<key> <string>list_action</string> </key>
<value> <string>Folder_viewContentList</string> </value>
<value> <string>Delivery_viewCheckbookInputDialog</string> </value>
</item>
<item>
<key> <string>list_method</string> </key>
......@@ -448,6 +448,10 @@
<list/>
</value>
</item>
<item>
<key> <string>page_template</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
......@@ -523,11 +527,8 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.MethodField</string>
<string>Method</string>
</tuple>
<none/>
<global name="Method" module="Products.Formulator.MethodField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......
......@@ -114,6 +114,7 @@
<value>
<list>
<string>my_price_currency</string>
<string>my_composition</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ListField" module="Products.Formulator.StandardFields"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_composition</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>unknown_selection</string> </key>
<value> <string>You selected an item that was not in the list.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Type of Check</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.getPortalType() == \'Checkbook Model\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\', \'\')] + [(x.getTitle(), x.getRelativeUrl()) for x in here.checkbook_model_module.objectValues(portal_type=\'Check Model\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -31,7 +31,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Validated By Vault Surface Manager</string> </value>
<value> <string>Validated By Vault Manager</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
......
......@@ -31,7 +31,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Vault Controler Validated</string> </value>
<value> <string>Controler Validated</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
......@@ -40,6 +40,7 @@
<string>confirm</string>
<string>confirm_action</string>
<string>deliver</string>
<string>order_to_deliver_action</string>
<string>reject</string>
<string>reject_action</string>
</tuple>
......
......@@ -31,7 +31,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Assigned To Vault Controler</string> </value>
<value> <string>Assigned To Controler</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
......
......@@ -67,15 +67,18 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.DCWorkflow.Guard</string>
<string>Guard</string>
</tuple>
<none/>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>roles</string> </key>
<value>
......@@ -88,4 +91,20 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="Expression" module="Products.CMFCore.Expression"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: here.getSource() is not None and "surface" in here.getSource()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -73,6 +73,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>roles</string> </key>
<value>
......@@ -85,4 +91,20 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="Expression" module="Products.CMFCore.Expression"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: here.getSource() is not None and "surface" in here.getSource()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string>Validate</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/BaseWorkflow_viewWorkflowActionDialog?workflow_action=order_to_deliver_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>deliver</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>order_to_deliver_action</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Validate Action</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>roles</string> </key>
<value>
<tuple>
<string>DestinationAssignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="Expression" module="Products.CMFCore.Expression"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: here.getSource() is not None and \'caveau\' in here.getSource()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
215
\ No newline at end of file
217
\ No newline at end of file
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