From 6ef49965fb0fb5e49eb45ebb34b3c3d6b5fb41f0 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Tue, 10 Jun 2008 12:44:56 +0000
Subject: [PATCH] add support of customisable Form Dialog in Relation Fields

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21465 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Base_getRelatedObjectColumnList.xml       | 21 ++++++++++++-------
 .../Base_getRelatedObjectParameter.xml        | 21 ++++++++++++-------
 product/ERP5/bootstrap/erp5_core/bt/revision  |  2 +-
 3 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectColumnList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectColumnList.xml
index 05deb3eef7..8e876c66ea 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectColumnList.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectColumnList.xml
@@ -3,11 +3,8 @@
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.PythonScripts.PythonScript</string>
-          <string>PythonScript</string>
-        </tuple>
-        <none/>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
@@ -68,10 +65,12 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>result = getattr(context, context.REQUEST.form_id, None).get_field( context.REQUEST.field_id ).get_value(\'columns\')\n
+            <value> <string>listbox = getattr(context, context.REQUEST.form_id, None).get_field( context.REQUEST.field_id )\n
+dialog_id = listbox.get_value(\'relation_form_id\') or \'Base_viewRelatedObjectList\'\n
+result = listbox.get_value(\'columns\')\n
 \n
 if result in [ [], (), None, \'\']:\n
-  result = getattr(context, \'Base_viewRelatedObjectList\', None).get_field( \'listbox\' ).get_value(\'columns\')\n
+  result = getattr(context, dialog_id, None).get_field( \'listbox\' ).get_value(\'columns\')\n
 \n
 return result\n
 </string> </value>
@@ -88,6 +87,12 @@ return result\n
               <none/>
             </value>
         </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
         <item>
             <key> <string>_params</string> </key>
             <value> <string></string> </value>
@@ -120,6 +125,8 @@ return result\n
                             <string>getattr</string>
                             <string>context</string>
                             <string>None</string>
+                            <string>listbox</string>
+                            <string>dialog_id</string>
                             <string>result</string>
                           </tuple>
                         </value>
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectParameter.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectParameter.xml
index 67c1b4df48..2f897c7004 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectParameter.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getRelatedObjectParameter.xml
@@ -3,11 +3,8 @@
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.PythonScripts.PythonScript</string>
-          <string>PythonScript</string>
-        </tuple>
-        <none/>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
@@ -72,11 +69,13 @@
 # by Base_viewRelatedObjectList from the relation field\n
 result = None\n
 if parameter is not None:\n
-  result = getattr(context, context.REQUEST.form_id, None).get_field( context.REQUEST.field_id ).get_value(parameter)\n
+  listbox = getattr(context, context.REQUEST.form_id, None).get_field( context.REQUEST.field_id )\n
+  dialog_id = listbox.get_value(\'relation_form_id\') or \'Base_viewRelatedObjectList\'\n
+  result = listbox.get_value(parameter)\n
 \n
   if result in [ [], (), None, \'\']:\n
     \n
-    result = getattr(context, \'Base_viewRelatedObjectList\', None).get_field( \'listbox\' ).get_orig_value(parameter)\n
+    result = getattr(context, dialog_id, None).get_field( \'listbox\' ).get_orig_value(parameter)\n
 \n
 return result\n
 </string> </value>
@@ -93,6 +92,12 @@ return result\n
               <none/>
             </value>
         </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
         <item>
             <key> <string>_params</string> </key>
             <value> <string>parameter=None,**kw</string> </value>
@@ -128,6 +133,8 @@ return result\n
                             <string>_getattr_</string>
                             <string>getattr</string>
                             <string>context</string>
+                            <string>listbox</string>
+                            <string>dialog_id</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index 885c7e85d7..f3daf1d568 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-834
\ No newline at end of file
+835
\ No newline at end of file
-- 
2.30.9