From 6cd511e4c2534ed4d9c7aae042616a7699d3e602 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Wed, 23 May 2007 13:19:14 +0000
Subject: [PATCH] added new script in order to retrieve a check model thanks to
 its reference

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14567 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../metadata.xml                              |   9 +-
 .../print.xml                                 |   7 +-
 .../view.xml                                  |   7 +-
 .../Base_getCheckModelByReference.xml         | 181 ++++++++++++++++++
 bt5/erp5_banking_core/bt/revision             |   2 +-
 5 files changed, 189 insertions(+), 17 deletions(-)
 create mode 100644 bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Base_getCheckModelByReference.xml

diff --git a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/metadata.xml b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/metadata.xml
index 48fee5a2af..9e1442f89a 100644
--- a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/metadata.xml
+++ b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/metadata.xml
@@ -67,18 +67,15 @@
   <record id="2" aka="AAAAAAAAAAI=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.CMFCore.Expression</string>
-          <string>Expression</string>
-        </tuple>
-        <none/>
+        <global name="Expression" module="Products.CMFCore.Expression"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
       <dictionary>
         <item>
             <key> <string>text</string> </key>
-            <value> <string>string:${object_url}/metadata_edit</string> </value>
+            <value> <string>string:${object_url}/Base_viewMetadata</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/print.xml b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/print.xml
index 2ad1817795..4d2d47de1c 100644
--- a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/print.xml
+++ b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/print.xml
@@ -67,11 +67,8 @@
   <record id="2" aka="AAAAAAAAAAI=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.CMFCore.Expression</string>
-          <string>Expression</string>
-        </tuple>
-        <none/>
+        <global name="Expression" module="Products.CMFCore.Expression"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
diff --git a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/view.xml b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/view.xml
index 2f8fe9c3e0..2b833b098d 100644
--- a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/view.xml
+++ b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Checkbook%20Model%20Check%20Amount%20Variation/view.xml
@@ -67,11 +67,8 @@
   <record id="2" aka="AAAAAAAAAAI=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.CMFCore.Expression</string>
-          <string>Expression</string>
-        </tuple>
-        <none/>
+        <global name="Expression" module="Products.CMFCore.Expression"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
diff --git a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Base_getCheckModelByReference.xml b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Base_getCheckModelByReference.xml
new file mode 100644
index 0000000000..310cb8735c
--- /dev/null
+++ b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Base_getCheckModelByReference.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
+      </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 encoding="cdata"><![CDATA[
+
+from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
+from Products.ERP5Type.Message import Message\n
+if reference is None:\n
+  msg = Message(domain=\'ui\', message="Check not defined.")\n
+  raise ValidationFailed, (msg,)\n
+model_list = [x for x in context.checkbook_model_module.objectValues()\n
+              if x.getReference()==reference]\n
+model_list_len = len(model_list)\n
+if model_list_len == 0:\n
+  msg = Message(domain=\'ui\', message="Check not defined.")\n
+  raise ValidationFailed, (msg,)\n
+if model_list_len > 1:\n
+  msg = Message(domain=\'ui\', message="Two many check models with this reference.")\n
+  raise ValidationFailed, (msg,)\n
+return model_list[0]\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>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>reference=None</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>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>reference</string>
+                            <string>Products.DCWorkflow.DCWorkflow</string>
+                            <string>ValidationFailed</string>
+                            <string>Products.ERP5Type.Message</string>
+                            <string>Message</string>
+                            <string>None</string>
+                            <string>msg</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
+                            <string>_getattr_</string>
+<string>context</string>
+                            <string>x</string>
+                            <string>model_list</string>
+                            <string>len</string>
+                            <string>model_list_len</string>
+                            <string>_getitem_</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <none/>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_getCheckModelByReference</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_banking_core/bt/revision b/bt5/erp5_banking_core/bt/revision
index 20ad60520b..7df2addf7b 100644
--- a/bt5/erp5_banking_core/bt/revision
+++ b/bt5/erp5_banking_core/bt/revision
@@ -1 +1 @@
-230
\ No newline at end of file
+232
\ No newline at end of file
-- 
2.30.9