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 ...@@ -71,7 +71,9 @@ from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n \n
# Check that a check exists for given bank account and reference.\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 result_len = len(result)\n
if result_len == 0:\n if result_len == 0:\n
msg = Message(domain=\'ui\', message="No such check")\n msg = Message(domain=\'ui\', message="No such check")\n
...@@ -120,7 +122,7 @@ return check\n ...@@ -120,7 +122,7 @@ return check\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>bank_account, reference</string> </value> <value> <string>bank_account, reference, resource</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -140,7 +142,7 @@ return check\n ...@@ -140,7 +142,7 @@ return check\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>3</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -148,6 +150,7 @@ return check\n ...@@ -148,6 +150,7 @@ return check\n
<tuple> <tuple>
<string>bank_account</string> <string>bank_account</string>
<string>reference</string> <string>reference</string>
<string>resource</string>
<string>Products.ERP5Type.Message</string> <string>Products.ERP5Type.Message</string>
<string>Message</string> <string>Message</string>
<string>Products.DCWorkflow.DCWorkflow</string> <string>Products.DCWorkflow.DCWorkflow</string>
......
...@@ -74,6 +74,8 @@ ...@@ -74,6 +74,8 @@
from Products.ERP5Type.Message import Message\n from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n \n
portal = context.getPortalObject()\n
\n
if bank_account is None:\n if bank_account is None:\n
if destination:\n if destination:\n
bank_account = context.getDestinationPaymentValue()\n bank_account = context.getDestinationPaymentValue()\n
...@@ -84,6 +86,10 @@ if bank_account is None:\n ...@@ -84,6 +86,10 @@ if bank_account is None:\n
msg = Message(domain=\'ui\',message=\'Sorry, you must select an account\')\n msg = Message(domain=\'ui\',message=\'Sorry, you must select an account\')\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
\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 if reference is not None:\n
reference_list = [reference]\n reference_list = [reference]\n
\n \n
...@@ -112,13 +118,18 @@ elif reference_range_min is not None or reference_range_max is not None:\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 reference_list.append(ref)\n
\n \n
check_list = []\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 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 # just raise an error.\n
if context.portal_activities.countMessageWithTag(message_tag) != 0:\n if context.portal_activities.countMessageWithTag(message_tag) != 0:\n
msg = Message(domain=\'ui\', message="This check number is already being indexed.")\n msg = Message(domain=\'ui\', message="This check number is already being indexed.")\n
raise ValidationFailed, (msg,)\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 len(result) == 0:\n
if not context.Base_isAutomaticCheckCreationAllowed():\n if not context.Base_isAutomaticCheckCreationAllowed():\n
msg = Message(domain = "ui", message="Sorry, this reference does not exist")\n msg = Message(domain = "ui", message="Sorry, this reference does not exist")\n
...@@ -127,23 +138,41 @@ for check_reference in reference_list:\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 # 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 # Get a checkbook for this bank account.\n
checkbook = None\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 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 # 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 # movement at the moment.\n
for brain in context.portal_catalog(portal_type = \'Checkbook\',\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 obj = brain.getObject()\n
if obj.getResourceUid() == generic_model.getUid():\n #if obj.getResourceUid() == generic_model.getUid():\n
checkbook = obj\n checkbook = obj\n
break\n # break\n
if checkbook is None:\n if checkbook is None:\n
# Create a checkbook.\n # Create a checkbook.\n
# To prevent duplicated checkbooks for a single bank account, index this new checkbook immediately.\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 # 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 checkbook = context.checkbook_module.newContent(portal_type = \'Checkbook\',\n
title = \'Generic\',\n
resource_value = generic_model,\n resource_value = generic_model,\n
destination_payment_value = bank_account,\n destination_payment_value = bank_account,\n
immediate_reindex = 1)\n activate_kw={\'tag\' : checkbook_tag} )\n
# Create a check.\n # Create a check.\n
check = checkbook.newContent(portal_type = \'Check\', reference = check_reference, activate_kw={\'tag\': message_tag})\n check = checkbook.newContent(portal_type = \'Check\', reference = check_reference, activate_kw={\'tag\': message_tag})\n
# Automatically issue this check.\n # Automatically issue this check.\n
...@@ -179,7 +208,7 @@ return check_list\n ...@@ -179,7 +208,7 @@ return check_list\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -199,7 +228,7 @@ return check_list\n ...@@ -199,7 +228,7 @@ return check_list\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>6</int> </value> <value> <int>7</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -211,13 +240,15 @@ return check_list\n ...@@ -211,13 +240,15 @@ return check_list\n
<string>source</string> <string>source</string>
<string>destination</string> <string>destination</string>
<string>bank_account</string> <string>bank_account</string>
<string>resource</string>
<string>Products.ERP5Type.Message</string> <string>Products.ERP5Type.Message</string>
<string>Message</string> <string>Message</string>
<string>Products.DCWorkflow.DCWorkflow</string> <string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string> <string>ValidationFailed</string>
<string>None</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</string>
<string>None</string>
<string>msg</string> <string>msg</string>
<string>reference_list</string> <string>reference_list</string>
<string>int</string> <string>int</string>
...@@ -226,15 +257,19 @@ return check_list\n ...@@ -226,15 +257,19 @@ return check_list\n
<string>range</string> <string>range</string>
<string>ref</string> <string>ref</string>
<string>check_list</string> <string>check_list</string>
<string>bank_account_uid</string>
<string>resource_value</string>
<string>generic_model</string>
<string>check_reference</string> <string>check_reference</string>
<string>message_tag</string> <string>message_tag</string>
<string>result</string> <string>result</string>
<string>len</string> <string>len</string>
<string>checkbook</string> <string>checkbook</string>
<string>composition_related_list</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>generic_model</string>
<string>brain</string> <string>brain</string>
<string>obj</string> <string>obj</string>
<string>checkbook_tag</string>
<string>check</string> <string>check</string>
</tuple> </tuple>
</value> </value>
...@@ -254,6 +289,7 @@ return check_list\n ...@@ -254,6 +289,7 @@ return check_list\n
<int>0</int> <int>0</int>
<int>1</int> <int>1</int>
<none/> <none/>
<none/>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -137,7 +137,7 @@ for line in context.getMovementList():\n ...@@ -137,7 +137,7 @@ for line in context.getMovementList():\n
<string>$append0</string> <string>$append0</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>x</string> <string>x</string>
<string>current_tracking_list</string> <string>current_tracking_list</string>
<string>aggregate_uid_list</string> <string>aggregate_uid_list</string>
......
...@@ -434,7 +434,7 @@ ...@@ -434,7 +434,7 @@
</item> </item>
<item> <item>
<key> <string>list_action</string> </key> <key> <string>list_action</string> </key>
<value> <string>Folder_viewContentList</string> </value> <value> <string>Delivery_viewCheckbookInputDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>list_method</string> </key> <key> <string>list_method</string> </key>
...@@ -448,6 +448,10 @@ ...@@ -448,6 +448,10 @@
<list/> <list/>
</value> </value>
</item> </item>
<item>
<key> <string>page_template</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>portal_types</string> </key> <key> <string>portal_types</string> </key>
<value> <value>
...@@ -523,11 +527,8 @@ ...@@ -523,11 +527,8 @@
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="Method" module="Products.Formulator.MethodField"/>
<string>Products.Formulator.MethodField</string> <tuple/>
<string>Method</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
......
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
<value> <value>
<list> <list>
<string>my_price_currency</string> <string>my_price_currency</string>
<string>my_composition</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Validated By Vault Surface Manager</string> </value> <value> <string>Validated By Vault Manager</string> </value>
</item> </item>
<item> <item>
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Vault Controler Validated</string> </value> <value> <string>Controler Validated</string> </value>
</item> </item>
<item> <item>
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<string>confirm</string> <string>confirm</string>
<string>confirm_action</string> <string>confirm_action</string>
<string>deliver</string> <string>deliver</string>
<string>order_to_deliver_action</string>
<string>reject</string> <string>reject</string>
<string>reject_action</string> <string>reject_action</string>
</tuple> </tuple>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Assigned To Vault Controler</string> </value> <value> <string>Assigned To Controler</string> </value>
</item> </item>
<item> <item>
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
......
...@@ -67,15 +67,18 @@ ...@@ -67,15 +67,18 @@
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="Guard" module="Products.DCWorkflow.Guard"/>
<string>Products.DCWorkflow.Guard</string> <tuple/>
<string>Guard</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>roles</string> </key> <key> <string>roles</string> </key>
<value> <value>
...@@ -88,4 +91,20 @@ ...@@ -88,4 +91,20 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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> </ZopeData>
...@@ -73,6 +73,12 @@ ...@@ -73,6 +73,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>roles</string> </key> <key> <string>roles</string> </key>
<value> <value>
...@@ -85,4 +91,20 @@ ...@@ -85,4 +91,20 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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> </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 217
\ No newline at end of file \ 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