From ca2fd9c4045167a21a8e75849224596ab9e18562 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <arnaud.fontaine@nexedi.com>
Date: Fri, 16 Dec 2011 16:28:24 +0900
Subject: [PATCH] Display "Own Section" along "Third Party" in
 AccountingTransactionModule_viewAccountingTransactionList.

---
 ...onModule_viewAccountingTransactionList.xml |   1 +
 .../listbox.xml                               |  12 +
 .../listbox_delivery_own_section_title.xml    | 275 ++++++++++++++++++
 ...onModule_zGetAccountingTransactionList.xml |  18 +-
 ...countingTransaction_getOwnSectionTitle.xml |  78 +++++
 bt5/erp5_accounting/bt/change_log             |   3 +
 bt5/erp5_accounting/bt/revision               |   2 +-
 7 files changed, 387 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox_delivery_own_section_title.xml
 create mode 100644 bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getOwnSectionTitle.xml

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList.xml
index 79665253c0..ab5514dfec 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList.xml
@@ -63,6 +63,7 @@
                     <value>
                       <list>
                         <string>listbox</string>
+                        <string>listbox_delivery_own_section_title</string>
                       </list>
                     </value>
                 </item>
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 a9aa95a9c7..71ab828d10 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
@@ -157,6 +157,10 @@
                     <key> <string>all_columns</string> </key>
                     <value>
                       <list>
+                        <tuple>
+                          <string>delivery_own_section_title</string>
+                          <string>Own Section</string>
+                        </tuple>
                         <tuple>
                           <string>translated_portal_type</string>
                           <string>Type</string>
@@ -293,6 +297,10 @@
                           <string>operation_date</string>
                           <string>operation_date</string>
                         </tuple>
+                        <tuple>
+                          <string>delivery_own_section_title</string>
+                          <string>delivery_own_section_title</string>
+                        </tuple>
                         <tuple>
                           <string>delivery_mirror_section_title</string>
                           <string>delivery_mirror_section_title</string>
@@ -381,6 +389,10 @@
                           <string>title</string>
                           <string>Title</string>
                         </tuple>
+                        <tuple>
+                          <string>delivery_own_section_title</string>
+                          <string>Own Section</string>
+                        </tuple>
                         <tuple>
                           <string>delivery_mirror_section_title</string>
                           <string>Third Party</string>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox_delivery_own_section_title.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox_delivery_own_section_title.xml
new file mode 100644
index 0000000000..9da7a64d40
--- /dev/null
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_viewAccountingTransactionList/listbox_delivery_own_section_title.xml
@@ -0,0 +1,275 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="StringField" module="Products.Formulator.StandardFields"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>listbox_delivery_own_section_title</string> </value>
+        </item>
+        <item>
+            <key> <string>message_values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>external_validator_failed</string> </key>
+                    <value> <string>The input failed the external validator.</string> </value>
+                </item>
+                <item>
+                    <key> <string>required_not_found</string> </key>
+                    <value> <string>Input is required but no input given.</string> </value>
+                </item>
+                <item>
+                    <key> <string>too_long</string> </key>
+                    <value> <string>Too much input was given.</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>overrides</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>alternate_name</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>css_class</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>display_maxwidth</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>display_width</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>editable</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>enabled</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>external_validator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>hidden</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>max_length</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>required</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>truncate</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>unicode</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>whitespace_preserve</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>alternate_name</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>css_class</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>display_maxwidth</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>display_width</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>editable</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>enabled</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>external_validator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>hidden</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>max_length</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>required</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>truncate</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>unicode</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>whitespace_preserve</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>alternate_name</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>css_class</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>display_maxwidth</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>display_width</string> </key>
+                    <value> <int>20</int> </value>
+                </item>
+                <item>
+                    <key> <string>editable</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>enabled</string> </key>
+                    <value> <int>1</int> </value>
+                </item>
+                <item>
+                    <key> <string>external_validator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>hidden</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>max_length</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>required</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Own Section</string> </value>
+                </item>
+                <item>
+                    <key> <string>truncate</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>unicode</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>whitespace_preserve</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string>cell/delivery_own_section_title|cell/AccountingTransaction_getOwnSectionTitle</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml
index 39a1ffaae2..52f4dd9804 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml
@@ -49,6 +49,7 @@ specific_reference\r\n
 group_by\r\n
 search_result_keys=\'\'\r\n
 delivery_mirror_section_title=""\r\n
+delivery_own_section_title=""\r\n
 source_section_where_expression\r\n
 destination_section_where_expression</string> </value>
         </item>
@@ -90,7 +91,7 @@ destination_section_where_expression</string> </value>
             <key> <string>src</string> </key>
             <value> <string encoding="cdata"><![CDATA[
 
-<dtml-let query="portal_catalog.buildSQLQuery(query=portal_catalog.getSecurityQuery(**selection_params), select_expression_key=(\'operation_date\', \'specific_reference\', \'delivery_mirror_section_title\',), **selection_params)">\n
+<dtml-let query="portal_catalog.buildSQLQuery(query=portal_catalog.getSecurityQuery(**selection_params), select_expression_key=(\'operation_date\', \'specific_reference\', \'delivery_mirror_section_title\', \'delivery_own_section_title\'), **selection_params)">\n
 <dtml-let search_result_keys="search_result_keys or portal_catalog.getCatalogSearchResultKeys()">\n
 <dtml-let use_movement_table="from_date or to_date or at_date or resource or stat or amount or amount_range_min or amount_range_max">\n
 <dtml-let accounting_movement_list="portal_url.getPortalObject().getPortalAccountingMovementTypeList()">\n
@@ -299,6 +300,7 @@ destination_section_where_expression</string> </value>
           <dtml-else>\n
            catalog.*,\n
           ( SELECT title FROM catalog as mirror_catalog WHERE mirror_catalog.uid=catalog.delivery_mirror_section_uid ) AS delivery_mirror_section_title,\n
+          ( SELECT title FROM catalog as own_catalog WHERE own_catalog.uid=catalog.delivery_own_section_uid ) AS delivery_own_section_title,\n
           ( SELECT IFNULL(SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = catalog.uid AND stock.section_uid=catalog.category_uid AND stock.total_price > 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS debit,\n
           ( SELECT IFNULL(-SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = catalog.uid AND stock.section_uid=catalog.category_uid AND stock.total_price < 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS credit\n
           </dtml-if>\n
@@ -325,6 +327,7 @@ destination_section_where_expression</string> </value>
             DISTINCT\n
             delivery.start_date as operation_date\n
             , delivery.destination_section_uid as delivery_mirror_section_uid\n
+            , delivery.source_section_uid as delivery_own_section_uid\n
             , \'source\' as section_mark\n
             , catalog.source_reference as specific_reference\n
             , catalog.*\n
@@ -355,6 +358,7 @@ destination_section_where_expression</string> </value>
               stock, catalog as child, </dtml-if>\n
           <dtml-if "section_category">category, catalog as section, </dtml-if>\n
           <dtml-if "delivery_mirror_section_title">delivery AS mirror_section_delivery, catalog AS mirror_section_catalog,</dtml-if>\n
+          <dtml-if "delivery_own_section_title">delivery AS own_section_delivery, catalog AS own_section_catalog,</dtml-if>\n
           catalog,\n
           delivery\n
         \n
@@ -420,6 +424,11 @@ destination_section_where_expression</string> </value>
             AND mirror_section_delivery.uid = catalog.uid\n
             AND <dtml-sqltest delivery_mirror_section_title type=string op=like column=mirror_section_catalog.title>\n
           </dtml-if>\n
+          <dtml-if "delivery_own_section_title">\n
+            AND own_section_catalog.uid = own_section_delivery.source_section_uid\n
+            AND own_section_delivery.uid = catalog.uid\n
+            AND <dtml-sqltest delivery_own_section_title type=string op=like column=own_section_catalog.title>\n
+          </dtml-if>\n
           \n
           <dtml-if from_date>\n
             AND delivery.start_date >= <dtml-sqlvar from_date type="datetime">\n
@@ -513,6 +522,7 @@ UNION\n
             DISTINCT\n
             delivery.stop_date as operation_date\n
             , delivery.source_section_uid as delivery_mirror_section_uid\n
+            , delivery.destination_section_uid as delivery_own_section_uid\n
             , \'destination\' as section_mark\n
             , catalog.destination_reference as specific_reference\n
             , catalog.*\n
@@ -543,6 +553,7 @@ UNION\n
               stock, catalog as child, </dtml-if>\n
           <dtml-if "section_category">category, catalog as section, </dtml-if>\n
           <dtml-if "delivery_mirror_section_title">delivery AS mirror_section_delivery, catalog AS mirror_section_catalog,</dtml-if>\n
+          <dtml-if "delivery_own_section_title">delivery AS own_section_delivery, catalog AS own_section_catalog,</dtml-if>\n
           catalog,\n
           delivery\n
         \n
@@ -608,6 +619,11 @@ UNION\n
             AND mirror_section_delivery.uid = catalog.uid\n
             AND <dtml-sqltest delivery_mirror_section_title type=string op=like column=mirror_section_catalog.title>\n
           </dtml-if>\n
+          <dtml-if "delivery_own_section_title">\n
+            AND own_section_catalog.uid = own_section_delivery.destination_section_uid\n
+            AND own_section_delivery.uid = catalog.uid\n
+            AND <dtml-sqltest delivery_own_section_title type=string op=like column=own_section_catalog.title>\n
+          </dtml-if>\n
 \n
           <dtml-if from_date>\n
             AND delivery.stop_date >= <dtml-sqlvar from_date type="datetime">\n
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getOwnSectionTitle.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getOwnSectionTitle.xml
new file mode 100644
index 0000000000..bd40aade41
--- /dev/null
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getOwnSectionTitle.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </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>if brain is not None:\n
+  transaction = brain.getObject()\n
+else:\n
+  transaction = context\n
+\n
+if transaction.AccountingTransaction_isSourceView():\n
+  own_section = transaction.getSourceSectionValue()\n
+else:\n
+  own_section = transaction.getDestinationSectionValue()\n
+\n
+if own_section is not None:\n
+  return own_section.getTitle()\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>brain=None, selection=None, selection_name=None, **kw</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>AccountingTransaction_getOwnSectionTitle</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_accounting/bt/change_log b/bt5/erp5_accounting/bt/change_log
index 6b4b96d316..d6b7f6c910 100644
--- a/bt5/erp5_accounting/bt/change_log
+++ b/bt5/erp5_accounting/bt/change_log
@@ -1,3 +1,6 @@
+2011-12-16 arnaud.fontaine
+* Display "Own Section" along "Third Party" in AccountingTransactionModule_viewAccountingTransactionList.
+
 2011-12-12 arnaud.fontaine
 * Display thousand separator of currency fields according to 'Money Quantity Style' user preference.
 
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index db60fd759b..029aeb486f 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-1473
\ No newline at end of file
+1474
\ No newline at end of file
-- 
2.30.9