From bd21cfc4666bf9bd385e2482159558bfefb57c5e Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Wed, 6 Aug 2008 12:11:15 +0000
Subject: [PATCH] make the script more generic

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22900 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Entity_getRelatedDocumentList.xml         | 23 +++++---
 .../Entity_viewDocumentList/listbox.xml       | 57 ++++++++++++++++++-
 2 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_getRelatedDocumentList.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_getRelatedDocumentList.xml
index be3f782701..297f48f2fa 100644
--- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_getRelatedDocumentList.xml
+++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_getRelatedDocumentList.xml
@@ -67,13 +67,16 @@
             <key> <string>_body</string> </key>
             <value> <string>portal = context.getPortalObject()\n
 portal_catalog = portal.portal_catalog\n
+path = "%" + "%s" % (context.getRelativeUrl()) + "%"\n
 \n
-# XXX This is not efficient.\n
-document_in_entity_list = portal_catalog(parent_uid=context.getUid(),\n
-                                         portal_type=(\'File\', \'Image\'))\n
 \n
-follow_up_document_list = portal_catalog(portal_type=portal.getPortalDocumentTypeList(),\n
-                                         follow_up_uid=context.getUid())\n
+# Get The documents in all storage structure. ie.: This scripts get all Files and Images\n
+# distributed in many Project Lines in one Project.\n
+\n
+document_in_entity_list = portal_catalog(path=path , portal_type=portal_type)\n
+\n
+follow_up_document_list = portal_catalog(portal_type=portal_type,\n
+                                                                             follow_up_uid=context.getUid())\n
 \n
 return list(document_in_entity_list)+list(follow_up_document_list)\n
 </string> </value>
@@ -92,7 +95,7 @@ return list(document_in_entity_list)+list(follow_up_document_list)\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>**kw</string> </value>
+            <value> <string>portal_type= [], **kw</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -112,17 +115,19 @@ return list(document_in_entity_list)+list(follow_up_document_list)\n
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>0</int> </value>
+                        <value> <int>1</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
+                            <string>portal_type</string>
                             <string>kw</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>portal</string>
                             <string>portal_catalog</string>
+                            <string>path</string>
                             <string>document_in_entity_list</string>
                             <string>follow_up_document_list</string>
                             <string>list</string>
@@ -137,7 +142,9 @@ return list(document_in_entity_list)+list(follow_up_document_list)\n
         <item>
             <key> <string>func_defaults</string> </key>
             <value>
-              <none/>
+              <tuple>
+                <list/>
+              </tuple>
             </value>
         </item>
         <item>
diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_viewDocumentList/listbox.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_viewDocumentList/listbox.xml
index f9a8b7fd7f..77e678c354 100644
--- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_viewDocumentList/listbox.xml
+++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Entity_viewDocumentList/listbox.xml
@@ -18,6 +18,7 @@
                 <string>all_columns</string>
                 <string>list_method</string>
                 <string>selection_name</string>
+                <string>portal_types</string>
                 <string>editable_columns</string>
               </list>
             </value>
@@ -60,6 +61,18 @@
             <key> <string>tales</string> </key>
             <value>
               <dictionary>
+                <item>
+                    <key> <string>all_columns</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>columns</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>editable_columns</string> </key>
+                    <value> <string></string> </value>
+                </item>
                 <item>
                     <key> <string>field_id</string> </key>
                     <value> <string></string> </value>
@@ -68,10 +81,28 @@
                     <key> <string>form_id</string> </key>
                     <value> <string></string> </value>
                 </item>
+                <item>
+                    <key> <string>list_method</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>portal_types</string> </key>
+                    <value>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>selection_name</string> </key>
+                    <value> <string></string> </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>
@@ -181,7 +212,13 @@
                 <item>
                     <key> <string>list_method</string> </key>
                     <value>
-                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                      <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>portal_types</string> </key>
+                    <value>
+                      <list/>
                     </value>
                 </item>
                 <item>
@@ -194,7 +231,7 @@
                 </item>
                 <item>
                     <key> <string>title</string> </key>
-                    <value> <string>Related Documents</string> </value>
+                    <value> <string>Documents</string> </value>
                 </item>
               </dictionary>
             </value>
@@ -203,6 +240,22 @@
     </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: [(t, t) for t in context.getPortalDocumentTypeList()]</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="3" aka="AAAAAAAAAAM=">
     <pickle>
       <tuple>
         <global name="Method" module="Products.Formulator.MethodField"/>
-- 
2.30.9