[Erp5-report] r14551 - in /erp5/trunk/bt5/erp5_banking_check: WorkflowTemplateItem/portal_w...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue May 22 20:33:27 CEST 2007


Author: vincent
Date: Tue May 22 20:33:27 2007
New Revision: 14551

URL: http://svn.erp5.org?rev=14551&view=rev
Log:
Internally remember which identifiers have been created to prevent the system from allowing to create the same check twice if done in the same reception.
Use composition category to remove the need for a dirty hack (string replacement).
Use paths instead of titles as part of identifiers.
Now that there is an object as part of the identifier, use serialize.
Resource is set differently if the object is a check or a checkbook, move and duplicate setter use downward.
Trigger a dummy tagged activity even when creating a check, like what's done when creating a checkbook.

Modified:
    erp5/trunk/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_reception_workflow/scripts/CheckbookReception_generateItemList.xml
    erp5/trunk/bt5/erp5_banking_check/bt/revision

Modified: erp5/trunk/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_reception_workflow/scripts/CheckbookReception_generateItemList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_reception_workflow/scripts/CheckbookReception_generateItemList.xml?rev=14551&r1=14550&r2=14551&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_reception_workflow/scripts/CheckbookReception_generateItemList.xml (original)
+++ erp5/trunk/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_reception_workflow/scripts/CheckbookReception_generateItemList.xml Tue May 22 20:33:27 2007
@@ -133,11 +133,13 @@
   """\n
     Check each given reference not to already exist.\n
   """\n
-  match_list = portal.portal_catalog(portal_type=\'Check\', reference=reference_list, destination_payment_uid=destination_payment.getUid())\n
+  destination_payment_uid = destination_payment.getUid()\n
+  match_list = portal.portal_catalog(portal_type=\'Check\', reference=reference_list, destination_payment_uid=destination_payment_uid, resource_relative_url=model)\n
   assertReferenceMatchListEmpty(match_list)\n
   for reference in reference_list:\n
-    if portal_activities.countMessageWithTag(\'check_%s_%s\' % (model, reference)) != 0:\n
-      raise ValidationFailed, \'This reference is alredy scheduled for indexing, and so is already allocated : %s\' % (reference, )\n
+    tag = \'check_%s_%s_%s\' % (model, destination_payment_uid, reference)\n
+    if encountered_check_identifiers_dict.has_key(tag) or portal_activities.countMessageWithTag(tag) != 0:\n
+      raise ValidationFailed, \'The following references are already allocated : %s\' % ([reference, ], )\n
 \n
 portal_activities = context.getPortalObject().portal_activities\n
 def checkReferenceUniqueness(reference, model, destination_payment):\n
@@ -156,6 +158,8 @@
 # generate all items. We do not need to check data\n
 # because everything is already checked in the fast input\n
 line_list = delivery.objectValues(portal_type=delivery.getPortalType() + \' Line\')\n
+\n
+encountered_check_identifiers_dict = {}\n
 \n
 for line in line_list:\n
   quantity = line.getQuantity()\n
@@ -169,7 +173,7 @@
   if resource_portal_type == \'Checkbook Model\':\n
     is_checkbook = True\n
     module = portal.checkbook_module\n
-    model = resource.getTitle().replace(\'Ch\xc3\xa9quier\', \'Ch\xc3\xa8que\') # XXX: Yuck yuck.\n
+    model = resource.getComposition()\n
     # XXX: portal_type value is hardcoded because I don\'t want to get the\n
     # portaltype on each created object as it will always be the same.\n
     # We need a method to get the default content portaltype on a Folder.\n
@@ -180,7 +184,7 @@
   else:\n
     is_checkbook = False\n
     module = portal.check_module\n
-    model = resource.getTitle()\n
+    model = resource.getRelativeUrl()\n
     # XXX: portal_type value is hardcoded, see XXX above.\n
     if resource_portal_type == \'Check Model\' and resource.isFixedPrice():\n
       reference_to_int = getTravelerCheckReferenceNumber\n
@@ -193,9 +197,10 @@
   for i in xrange(quantity):\n
     item = module.newContent()\n
     item.setDestinationPayment(line.getDestinationPayment())\n
+    item.getDestinationPaymentValue().serialize() # To prevent multiple zeo nodes from creating checks for the same account, since they would not be able to see each other\'s activities.\n
     item.setDestinationTrade(line.getDestinationTrade())\n
-    item.setResourceValue(resource)\n
     if is_checkbook:\n
+      item.setResourceValue(resource)\n
       item.setReferenceRangeMin(reference_range_min)\n
       last_reference_value = reference_to_int(reference_range_min) + check_quantity - 1\n
       reference_range_max = int_to_reference(last_reference_value, reference_range_min)\n
@@ -208,21 +213,30 @@
       item.setStartDate(start_date)\n
       reference_list = range(reference_to_int(reference_range_min), last_reference_value + 1)\n
       checkReferenceListUniqueness(reference_list, model, item.getDestinationPaymentValue())\n
+      destination_payment_uid = item.getDestinationPaymentValue().getUid()\n
       for j in reference_list:\n
         reference = int_to_reference(j, reference_range_min)\n
-        check = item.newContent(portal_type=\'Check\', title=str(reference), activate_kw={\'tag\': \'check_%s_%s\' % (model, reference)})\n
+        tag = \'check_%s_%s_%s\' % (model, destination_payment_uid, reference)\n
+        encountered_check_identifiers_dict[tag] = None\n
+        check = item.newContent(portal_type=\'Check\', title=str(reference), activate_kw={\'tag\': tag})\n
         check.setDestination(destination_section)\n
         check.setStartDate(start_date)\n
         check.setReference(reference)\n
+        check.setResource(model)\n
     else:\n
       checkReferenceUniqueness(reference_range_min, model, line.getDestinationPaymentValue())\n
       item.setReference(reference_range_min)\n
+      item.setResource(model)\n
       item.setTitle(reference_range_min)\n
       if len(resource.objectValues()) > 0:\n
         item_type = line.getCheckTypeValue()\n
         item.setPrice(item_type.getPrice())\n
         item.setPriceCurrency(line.getPriceCurrency())\n
       last_reference_value = reference_to_int(reference_range_min)\n
+      # Trigger a dummy activity just to avoi dbeing able to create that check multiple times in the same checkbook reception\n
+      tag = \'check_%s_%s_%s\' % (model, line.getDestinationPaymentValue().getUid(), reference_range_min)\n
+      encountered_check_identifiers_dict[tag] = None\n
+      item.activate(tag=tag).getUid()\n
     # update reference_range_min for the next pass\n
     reference_range_min = int_to_reference(last_reference_value + 1, reference_range_min)\n
     # I (seb) think this is a big mistake\n
@@ -296,6 +310,7 @@
                             <string>generateTravelerCheckReference</string>
                             <string>assertReferenceMatchListEmpty</string>
                             <string>portal</string>
+                            <string>encountered_check_identifiers_dict</string>
                             <string>portal_activities</string>
                             <string>checkReferenceListUniqueness</string>
                             <string>context</string>
@@ -328,8 +343,12 @@
                             <string>destination_section</string>
                             <string>range</string>
                             <string>reference_list</string>
+                            <string>destination_payment_uid</string>
                             <string>j</string>
                             <string>reference</string>
+                            <string>tag</string>
+                            <string>None</string>
+                            <string>_write_</string>
                             <string>str</string>
                             <string>check</string>
                             <string>len</string>

Modified: erp5/trunk/bt5/erp5_banking_check/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_banking_check/bt/revision?rev=14551&r1=14550&r2=14551&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_banking_check/bt/revision (original)
+++ erp5/trunk/bt5/erp5_banking_check/bt/revision Tue May 22 20:33:27 2007
@@ -1,1 +1,1 @@
-208
+215




More information about the Erp5-report mailing list