From 8fb0352065ee22dfcc2163ceba7d6a7a4b569680 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 12 May 2009 09:33:04 +0000
Subject: [PATCH] show editable fields on lines for payment

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26919 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...untingTransaction_getListBoxColumnList.xml |  42 +++++-
 .../PaymentTransaction_view.xml               |   1 +
 .../PaymentTransaction_view/listbox.xml       |  20 ++-
 .../listbox_source_payment.xml                | 132 ++++++++++++++++++
 .../PaymentTransaction_viewDestination.xml    |   1 +
 .../listbox.xml                               |  20 ++-
 .../listbox_destination_payment.xml           | 132 ++++++++++++++++++
 bt5/erp5_accounting/bt/revision               |   2 +-
 8 files changed, 333 insertions(+), 17 deletions(-)
 create mode 100644 bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox_source_payment.xml
 create mode 100644 bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox_destination_payment.xml

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getListBoxColumnList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getListBoxColumnList.xml
index b7344f44e7..6d181bcb22 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getListBoxColumnList.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getListBoxColumnList.xml
@@ -61,9 +61,11 @@ If there is more than one mirror_section on lines, the listbox will have an\n
 extra column showing mirror_section_title.\n
 The same for apply for payment / payment_reference.\n
 """\n
+movement_type_list = context.getPortalAccountingMovementTypeList()\n
+\n
 section_dict = {None: 1}\n
 payment_dict = {None: 1}\n
-for line in context.getMovementList():\n
+for line in context.getMovementList(portal_type=movement_type_list):\n
   section_dict[line.getSourceSection()] = 1\n
   section_dict[line.getDestinationSection()] = 1\n
   payment_dict[line.getSourcePayment()] = 1\n
@@ -84,6 +86,23 @@ else:\n
 multiple_sections = len(section_dict) > min_section_count\n
 multiple_payment = len(payment_dict) > min_payment_count\n
 \n
+# we also show multiple payments if there is more than one "asset/cash/bank" account\n
+# used on this side.\n
+bank_type_account_count = 0\n
+if not multiple_payment and context.getPortalType() == \'Payment Transaction\':\n
+  for line in context.getMovementList(portal_type=movement_type_list):\n
+    if source:\n
+      account = line.getSourceValue(portal_type=\'Account\')\n
+    else:\n
+      account = line.getDestinationValue(portal_type=\'Account\')\n
+    if account is not None and \\\n
+          account.isMemberOf(\'account_type/asset/cash/bank\'):\n
+      bank_type_account_count += 1\n
+    if bank_type_account_count > 1:\n
+      multiple_payment = 1\n
+      break\n
+\n
+\n
 column_item_list = [(\'translated_id\', \'ID\')]\n
 a = column_item_list.append\n
 if source:\n
@@ -96,10 +115,17 @@ if multiple_sections:\n
   else:\n
     a((\'getSourceSectionTitle\', \'Third Party\'))\n
 if multiple_payment:\n
-  if source:\n
-    a((\'getSourcePaymentReference\', \'Bank Account\'))\n
+  if context.getPortalType() == \'Payment Transaction\':\n
+    if source:\n
+      a((\'source_payment\', \'Bank Account\'))\n
+    else:\n
+      a((\'destination_payment\', \'Bank Account\'))\n
   else:\n
-    a((\'getDestinationPaymentReference\', \'Bank Account\'))\n
+    if source:\n
+      a((\'getSourcePaymentReference\', \'Bank Account\'))\n
+    else:\n
+      a((\'getDestinationPaymentReference\', \'Bank Account\'))\n
+\n
 if source:\n
   a((\'source_debit\', \'Debit\'))\n
   a((\'source_credit\', \'Credit\'))\n
@@ -147,12 +173,13 @@ return column_item_list\n
                         <value>
                           <tuple>
                             <string>source</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>movement_type_list</string>
                             <string>None</string>
                             <string>section_dict</string>
                             <string>payment_dict</string>
                             <string>_getiter_</string>
-                            <string>_getattr_</string>
-                            <string>context</string>
                             <string>line</string>
                             <string>_write_</string>
                             <string>min_payment_count</string>
@@ -160,6 +187,9 @@ return column_item_list\n
                             <string>len</string>
                             <string>multiple_sections</string>
                             <string>multiple_payment</string>
+                            <string>bank_type_account_count</string>
+                            <string>account</string>
+                            <string>_inplacevar_</string>
                             <string>column_item_list</string>
                             <string>a</string>
                           </tuple>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view.xml
index 788abd1669..deac179cdc 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view.xml
@@ -85,6 +85,7 @@
                         <string>listbox_source</string>
                         <string>listbox_source_debit</string>
                         <string>listbox_source_credit</string>
+                        <string>listbox_source_payment</string>
                       </list>
                     </value>
                 </item>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox.xml
index b132936d1d..5bf8b4ece0 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox.xml
@@ -13,15 +13,15 @@
             <key> <string>delegated_list</string> </key>
             <value>
               <list>
-                <string>stat_columns</string>
-                <string>editable_columns</string>
-                <string>stat_method</string>
                 <string>title</string>
-                <string>selection_name</string>
                 <string>columns</string>
                 <string>list_method</string>
-                <string>anchor</string>
+                <string>stat_method</string>
+                <string>selection_name</string>
                 <string>portal_types</string>
+                <string>anchor</string>
+                <string>editable_columns</string>
+                <string>stat_columns</string>
               </list>
             </value>
         </item>
@@ -141,6 +141,10 @@
                           <string>source</string>
                           <string>Account</string>
                         </tuple>
+                        <tuple>
+                          <string>source_payment</string>
+                          <string>Bank Account</string>
+                        </tuple>
                       </list>
                     </value>
                 </item>
@@ -158,6 +162,12 @@
                       <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
                     </value>
                 </item>
+                <item>
+                    <key> <string>portal_types</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
                 <item>
                     <key> <string>selection_name</string> </key>
                     <value> <string>payment_transaction_selection</string> </value>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox_source_payment.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox_source_payment.xml
new file mode 100644
index 0000000000..8d6af6a1cf
--- /dev/null
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_view/listbox_source_payment.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>delegated_list</string> </key>
+            <value>
+              <list>
+                <string>title</string>
+                <string>items</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>listbox_source_payment</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>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>overrides</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>items</string> </key>
+                    <value>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_list_field</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewAccountingFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>items</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Section Bank Account</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string>python:here.AccountingTransaction_getSourcePaymentItemList()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination.xml
index 18e6bf96b5..b8f6e9dfa8 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination.xml
@@ -100,6 +100,7 @@
                         <string>my_reference</string>
                         <string>my_resource</string>
                         <string>my_payment_mode</string>
+                        <string>listbox_destination_payment</string>
                       </list>
                     </value>
                 </item>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox.xml
index 5cd2f1edd8..95b0e51c70 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox.xml
@@ -13,15 +13,15 @@
             <key> <string>delegated_list</string> </key>
             <value>
               <list>
-                <string>stat_columns</string>
-                <string>editable_columns</string>
-                <string>stat_method</string>
                 <string>title</string>
-                <string>selection_name</string>
                 <string>columns</string>
                 <string>list_method</string>
-                <string>anchor</string>
+                <string>stat_method</string>
+                <string>selection_name</string>
                 <string>portal_types</string>
+                <string>anchor</string>
+                <string>editable_columns</string>
+                <string>stat_columns</string>
               </list>
             </value>
         </item>
@@ -141,6 +141,10 @@
                           <string>destination</string>
                           <string>Account</string>
                         </tuple>
+                        <tuple>
+                          <string>destination_payment</string>
+                          <string>Section Bank Account</string>
+                        </tuple>
                       </list>
                     </value>
                 </item>
@@ -158,6 +162,12 @@
                       <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
                     </value>
                 </item>
+                <item>
+                    <key> <string>portal_types</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
                 <item>
                     <key> <string>selection_name</string> </key>
                     <value> <string>payment_transaction_destination_selection</string> </value>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox_destination_payment.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox_destination_payment.xml
new file mode 100644
index 0000000000..9b3cd2f78b
--- /dev/null
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/PaymentTransaction_viewDestination/listbox_destination_payment.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>delegated_list</string> </key>
+            <value>
+              <list>
+                <string>title</string>
+                <string>items</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>listbox_destination_payment</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>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>overrides</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>items</string> </key>
+                    <value>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_list_field</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewAccountingFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>items</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Section Bank Account</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string>python:here.AccountingTransaction_getDestinationPaymentItemList()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index e517ae7abf..7e752471bf 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-917
\ No newline at end of file
+918
\ No newline at end of file
-- 
2.30.9