From 1cef582eaf9128ee32ef593d3c041a1c965d5ffc Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 27 Jul 2007 12:47:51 +0000
Subject: [PATCH] Use getSourceTrade to determine document's site. Exchanged
 Mutilated Banknote must not be in headquater's stock, only in agency's, and
 only in 2 workflow states.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15359 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...latedBanknoteLine_getBaobabDestination.xml | 24 ++++++-------------
 .../transitions/deliver_action.xml            | 16 ++++---------
 .../transitions/plan_action.xml               | 16 ++++---------
 bt5/erp5_banking_cash/bt/revision             |  2 +-
 4 files changed, 18 insertions(+), 40 deletions(-)

diff --git a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/ExchangedMutilatedBanknoteLine_getBaobabDestination.xml b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/ExchangedMutilatedBanknoteLine_getBaobabDestination.xml
index a9b3babd0c..68de7f673e 100644
--- a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/ExchangedMutilatedBanknoteLine_getBaobabDestination.xml
+++ b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/ExchangedMutilatedBanknoteLine_getBaobabDestination.xml
@@ -65,19 +65,11 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>destination = "%s/surface/caisse_courante/encaisse_des_billets_et_monnaies" %(context.getSourceTrade(),)\n
-\n
-# If it was sent to headquarters, the destination\n
-# must be None\n
-parent = context.getParentValue()\n
-for workflow_item in \\\n
-     parent.Base_getWorkflowHistoryItemList(\'mutilated_banknote_workflow\',\n
-     display=0):\n
-  if workflow_item.state == \'planned\':\n
-    destination = None\n
-    break\n
-\n
-return destination\n
+            <value> <string>mutilated_banknote = context.getParentValue()\n
+mutilated_banknote_source_trade = mutilated_banknote.getSourceTrade(\'\')\n
+if \'siege\' not in mutilated_banknote_source_trade and mutilated_banknote.getWorkflowState() in (\'finished\', \'delivered\'):\n
+  return "%s/surface/caisse_courante/encaisse_des_billets_et_monnaies" % (mutilated_banknote_source_trade, )\n
+return None\n
 </string> </value>
         </item>
         <item>
@@ -130,10 +122,8 @@ return destination\n
                             <string>kw</string>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>destination</string>
-                            <string>parent</string>
-                            <string>_getiter_</string>
-                            <string>workflow_item</string>
+                            <string>mutilated_banknote</string>
+                            <string>mutilated_banknote_source_trade</string>
                             <string>None</string>
                           </tuple>
                         </value>
diff --git a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/deliver_action.xml b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/deliver_action.xml
index 33608e98dc..dec644309e 100644
--- a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/deliver_action.xml
+++ b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/deliver_action.xml
@@ -67,11 +67,8 @@
   <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>
@@ -97,18 +94,15 @@
   <record id="3" aka="AAAAAAAAAAM=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.CMFCore.Expression</string>
-          <string>Expression</string>
-        </tuple>
-        <none/>
+        <global name="Expression" module="Products.CMFCore.Expression"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
       <dictionary>
         <item>
             <key> <string>text</string> </key>
-            <value> <string>python: "siege" not in here.getSource("")</string> </value>
+            <value> <string>python: "siege" not in here.getSourceTrade("")</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/plan_action.xml b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/plan_action.xml
index 5069672351..8c63746713 100644
--- a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/plan_action.xml
+++ b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/mutilated_banknote_workflow/transitions/plan_action.xml
@@ -67,11 +67,8 @@
   <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>
@@ -97,18 +94,15 @@
   <record id="3" aka="AAAAAAAAAAM=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.CMFCore.Expression</string>
-          <string>Expression</string>
-        </tuple>
-        <none/>
+        <global name="Expression" module="Products.CMFCore.Expression"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
       <dictionary>
         <item>
             <key> <string>text</string> </key>
-            <value> <string>python: "siege" not in here.getSource("")</string> </value>
+            <value> <string>python: "siege" not in here.getSourceTrade("")</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_banking_cash/bt/revision b/bt5/erp5_banking_cash/bt/revision
index fb8a210573..bc56e7649a 100644
--- a/bt5/erp5_banking_cash/bt/revision
+++ b/bt5/erp5_banking_cash/bt/revision
@@ -1 +1 @@
-428
\ No newline at end of file
+431
\ No newline at end of file
-- 
2.30.9