From 11457ad0fe665bbed662d8f01123e0256b42a0d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 8 Sep 2006 14:11:31 +0000
Subject: [PATCH] Fix Accounting Transaction Module to display the Third Party
 instead of the destination section.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9768 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...ingTransactionModule_getThirdPartyUrl.xml} |  46 +++--
 .../listbox.xml                               |  20 ++-
 ...countingTransaction_getThirdPartyTitle.xml | 157 ++++++++++++++++++
 bt5/erp5_accounting/bt/revision               |   2 +-
 4 files changed, 189 insertions(+), 36 deletions(-)
 rename bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/{AccountingTransactionModule_getDestinationSectionUrl.xml => AccountingTransactionModule_getThirdPartyUrl.xml} (79%)
 create mode 100644 bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyTitle.xml

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getDestinationSectionUrl.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getThirdPartyUrl.xml
similarity index 79%
rename from bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getDestinationSectionUrl.xml
rename to bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getThirdPartyUrl.xml
index 4e0c0b6d6d..307daf7255 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getDestinationSectionUrl.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getThirdPartyUrl.xml
@@ -68,23 +68,21 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>from ZTUtils import make_query\n
+            <value> <string>section_category=selection.getParams().get(\'section_category\')\n
+if not section_category:\n
+  return\n
 \n
-index = selection.getIndex()\n
-name = selection.getName()\n
-object = brain.getObject()\n
-if object is None:\n
-  return None\n
-destination_section = object.getDestinationSectionValue()\n
-if destination_section is None:\n
-  return None\n
-url = destination_section.absolute_url()\n
-method = \'Entity_viewAccountingTransactionList\'\n
-kw = { \n
-       \'reset\' : \'1\', \n
-     }\n
+transaction = brain.getObject()\n
+source_section = transaction.getSourceSectionValue()\n
 \n
-return url + \'/\' + method + \'?\' + make_query(kw)\n
+if source_section is not None and source_section.isMemberOf(section_category):\n
+  mirror_section = transaction.getDestinationSectionValue()\n
+else:\n
+  mirror_section = transaction.getSourceSectionValue()\n
+\n
+if mirror_section is not None:\n
+  return "%s/Entity_viewAccountingTransactionList?reset:int=1" %\\\n
+                     mirror_section.absolute_url()\n
 </string> </value>
         </item>
         <item>
@@ -101,7 +99,7 @@ return url + \'/\' + method + \'?\' + make_query(kw)\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>brain=None, selection=None, **kwd</string> </value>
+            <value> <string>brain, selection=None, **kwd</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -130,17 +128,12 @@ return url + \'/\' + method + \'?\' + make_query(kw)\n
                             <string>brain</string>
                             <string>selection</string>
                             <string>kwd</string>
-                            <string>ZTUtils</string>
-                            <string>make_query</string>
                             <string>_getattr_</string>
-                            <string>index</string>
-                            <string>name</string>
-                            <string>object</string>
+                            <string>section_category</string>
+                            <string>transaction</string>
+                            <string>source_section</string>
                             <string>None</string>
-                            <string>destination_section</string>
-                            <string>url</string>
-                            <string>method</string>
-                            <string>kw</string>
+                            <string>mirror_section</string>
                           </tuple>
                         </value>
                     </item>
@@ -154,13 +147,12 @@ return url + \'/\' + method + \'?\' + make_query(kw)\n
             <value>
               <tuple>
                 <none/>
-                <none/>
               </tuple>
             </value>
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>AccountingTransactionModule_getDestinationSectionUrl</string> </value>
+            <value> <string>AccountingTransactionModule_getThirdPartyUrl</string> </value>
         </item>
         <item>
             <key> <string>warnings</string> </key>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox.xml
index af770afd87..5e3b3f1f8e 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox.xml
@@ -334,8 +334,8 @@
                           <string>Title</string>
                         </tuple>
                         <tuple>
-                          <string>default_destination_section_title</string>
-                          <string>Destination</string>
+                          <string>AccountingTransaction_getThirdPartyTitle</string>
+                          <string>Third Party</string>
                         </tuple>
                         <tuple>
                           <string>translated_portal_type</string>
@@ -403,8 +403,8 @@
                           <string>Title</string>
                         </tuple>
                         <tuple>
-                          <string>default_destination_section_title</string>
-                          <string>Destination</string>
+                          <string>AccountingTransaction_getThirdPartyTitle</string>
+                          <string>Third Party</string>
                         </tuple>
                         <tuple>
                           <string>translated_portal_type</string>
@@ -539,6 +539,10 @@
                     <key> <string>not_viewable</string> </key>
                     <value> <int>0</int> </value>
                 </item>
+                <item>
+                    <key> <string>page_template</string> </key>
+                    <value> <string></string> </value>
+                </item>
                 <item>
                     <key> <string>portal_types</string> </key>
                     <value>
@@ -601,8 +605,8 @@
                           <string>Title</string>
                         </tuple>
                         <tuple>
-                          <string>default_destination_section_title</string>
-                          <string>Destination</string>
+                          <string>AccountingTransaction_getThirdPartyTitle</string>
+                          <string>Third Party</string>
                         </tuple>
                         <tuple>
                           <string>translated_portal_type</string>
@@ -682,8 +686,8 @@
                     <value>
                       <list>
                         <tuple>
-                          <string>default_destination_section_title</string>
-                          <string>AccountingTransactionModule_getDestinationSectionUrl</string>
+                          <string>AccountingTransaction_getThirdPartyTitle</string>
+                          <string>AccountingTransactionModule_getThirdPartyUrl</string>
                         </tuple>
                       </list>
                     </value>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyTitle.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyTitle.xml
new file mode 100644
index 0000000000..eb107b4f19
--- /dev/null
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyTitle.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.PythonScripts.PythonScript</string>
+          <string>PythonScript</string>
+        </tuple>
+        <none/>
+      </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>section_category=selection.getParams().get(\'section_category\')\n
+if not section_category:\n
+  return\n
+\n
+transaction = brain.getObject()\n
+source_section = transaction.getSourceSectionValue()\n
+if source_section is not None and source_section.isMemberOf(section_category):\n
+  return transaction.getDestinationSectionTitle()\n
+return transaction.getSourceSectionTitle()\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>_params</string> </key>
+            <value> <string>brain, selection, **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>2</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>brain</string>
+                            <string>selection</string>
+                            <string>kw</string>
+                            <string>_getattr_</string>
+                            <string>section_category</string>
+                            <string>transaction</string>
+                            <string>source_section</string>
+                            <string>None</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>AccountingTransaction_getThirdPartyTitle</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index a5c750feac..d99e90eb96 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-27
\ No newline at end of file
+29
\ No newline at end of file
-- 
2.30.9