From 401669c8429b8e801bcb7ab417e5190b0d90052f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Fri, 13 Apr 2007 14:58:12 +0000
Subject: [PATCH] fix destination/source script

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14075 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../CounterRendering_getBaobabSource.xml      | 168 ++++++++++++++++++
 ...ernalMoneyDeposit_getBaobabDestination.xml |  31 ++--
 bt5/erp5_banking_cash/bt/revision             |   2 +-
 3 files changed, 181 insertions(+), 20 deletions(-)
 create mode 100644 bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/CounterRendering_getBaobabSource.xml

diff --git a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/CounterRendering_getBaobabSource.xml b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/CounterRendering_getBaobabSource.xml
new file mode 100644
index 0000000000..9321e7e367
--- /dev/null
+++ b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/CounterRendering_getBaobabSource.xml
@@ -0,0 +1,168 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
+      </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>source = context.getSource()\n
+if source is not None:\n
+  return source\n
+# calculate the source\n
+# must use owner to know site letter\n
+site_list = context.Baobab_getUserAssignedSiteList(user_id=context.Base_getOwnerId())\n
+for site in site_list:\n
+  if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'/guichet\'):\n
+    return site\n
+from Products.ERP5Type.Message import Message\n
+message = Message(domain="ui", message="Object owner is not assigned to a counter.")\n
+raise ValueError,message\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </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>*args, **kw</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>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>args</string>
+                            <string>kw</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>source</string>
+                            <string>None</string>
+                            <string>site_list</string>
+                            <string>_getiter_</string>
+                            <string>site</string>
+                            <string>Products.ERP5Type.Message</string>
+                            <string>Message</string>
+                            <string>message</string>
+                            <string>ValueError</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>CounterRendering_getBaobabSource</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/InternalMoneyDeposit_getBaobabDestination.xml b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/InternalMoneyDeposit_getBaobabDestination.xml
index 51a9653343..ba92775d97 100644
--- a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/InternalMoneyDeposit_getBaobabDestination.xml
+++ b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/InternalMoneyDeposit_getBaobabDestination.xml
@@ -66,20 +66,17 @@
         <item>
             <key> <string>_body</string> </key>
             <value> <string>destination = context.getDestination()\n
-if destination is None:\n
-  return None\n
-user_id = context.Base_getLastUserIdByTransition(workflow_id=\'internal_money_deposit_workflow\', transition_id=\'deliver_action\')\n
-if user_id is None:\n
-  return None\n
-site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
+if destination is not None:\n
+  return destination+\'/encaisse_des_billets_et_monnaies/entrante\'\n
+# calculate the destination\n
+# must use owner to know site letter\n
+site_list = context.Baobab_getUserAssignedSiteList(user_id=context.Base_getOwnerId())\n
 for site in site_list:\n
-#   if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\') and (destination in site or site in destination):\n
-  if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\') and destination in site:\n
-    return site + \'/encaisse_des_billets_et_monnaies/entrante\'\n
-from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
+  if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'/guichet\'):\n
+    return site+"/entrante"\n
 from Products.ERP5Type.Message import Message\n
-msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
-raise ValidationFailed, (msg,)\n
+message = Message(domain="ui", message="Object owner is not assigned to a counter.")\n
+raise ValueError,message\n
 </string> </value>
         </item>
         <item>
@@ -102,7 +99,7 @@ raise ValidationFailed, (msg,)\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>*args, **kw</string> </value>
+            <value> <string></string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -128,21 +125,17 @@ raise ValidationFailed, (msg,)\n
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
-                            <string>args</string>
-                            <string>kw</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>destination</string>
                             <string>None</string>
-                            <string>user_id</string>
                             <string>site_list</string>
                             <string>_getiter_</string>
                             <string>site</string>
-                            <string>Products.DCWorkflow.DCWorkflow</string>
-                            <string>ValidationFailed</string>
                             <string>Products.ERP5Type.Message</string>
                             <string>Message</string>
-                            <string>msg</string>
+                            <string>message</string>
+                            <string>ValueError</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_banking_cash/bt/revision b/bt5/erp5_banking_cash/bt/revision
index 61f9147fdc..6610e117a3 100644
--- a/bt5/erp5_banking_cash/bt/revision
+++ b/bt5/erp5_banking_cash/bt/revision
@@ -1 +1 @@
-275
\ No newline at end of file
+277
\ No newline at end of file
-- 
2.30.9