From c5371b81959906c4dfc24faf3393be0bb99085d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Tue, 1 Jul 2008 09:07:18 +0000
Subject: [PATCH] - create script for fetching possible transformations on
 production order line - add listfield, which is able represent list of
 possible transformations to field library

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22135 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...Line_getResourceTransformationItemList.xml | 179 ++++++++++++++++++
 .../ProductionOrderLine_viewFieldLibrary.xml  |   1 +
 .../my_specialise.xml                         | 132 +++++++++++++
 bt5/erp5_mrp/bt/revision                      |   2 +-
 4 files changed, 313 insertions(+), 1 deletion(-)
 create mode 100644 bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/OrderLine_getResourceTransformationItemList.xml
 create mode 100644 bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary/my_specialise.xml

diff --git a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/OrderLine_getResourceTransformationItemList.xml b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/OrderLine_getResourceTransformationItemList.xml
new file mode 100644
index 0000000000..c7911b92dd
--- /dev/null
+++ b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/OrderLine_getResourceTransformationItemList.xml
@@ -0,0 +1,179 @@
+<?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>portal = context.getPortalObject()\n
+from ZTUtils import LazyFilter\n
+resource = context.getResourceValue()\n
+\n
+result = []\n
+\n
+if include_empty:\n
+  result.append([\'\',\'\'])\n
+if resource is None:\n
+  return result\n
+\n
+# XXX: Is it possible to use cache? Hook it on resource?\n
+for transformation in LazyFilter(\n
+  resource.getResourceRelatedValueList(portal_type=\'Transformation\'),\n
+  skip=\'View\'\n
+  ):\n
+  if not skip_invalidated or transformation.getProperty(\'validation_state\',\'default\') != \'invalidated\':\n
+    result.append( (transformation.getTitle(),transformation.getRelativeUrl()) )\n
+\n
+result.sort(lambda x,y: cmp(x[0], y[0]) )\n
+return result\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>include_empty=1, skip_invalidated=1</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>2</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>include_empty</string>
+                            <string>skip_invalidated</string>
+                            <string>_getattr_</string>
+<string>context</string>
+                            <string>portal</string>
+                            <string>ZTUtils</string>
+                            <string>LazyFilter</string>
+                            <string>resource</string>
+                            <string>result</string>
+                            <string>None</string>
+                            <string>_getiter_</string>
+                            <string>transformation</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <int>1</int>
+                <int>1</int>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>OrderLine_getResourceTransformationItemList</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary.xml b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary.xml
index c91555cca7..a38fd829ff 100644
--- a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary.xml
+++ b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary.xml
@@ -111,6 +111,7 @@
                         <string>my_title</string>
                         <string>my_int_index</string>
                         <string>my_reference</string>
+                        <string>my_specialise</string>
                       </list>
                     </value>
                 </item>
diff --git a/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary/my_specialise.xml b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary/my_specialise.xml
new file mode 100644
index 0000000000..564642683f
--- /dev/null
+++ b/bt5/erp5_mrp/SkinTemplateItem/portal_skins/erp5_mrp/ProductionOrderLine_viewFieldLibrary/my_specialise.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>my_specialise</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_category</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewFieldLibrary</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>Transformation</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.OrderLine_getResourceTransformationItemList()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_mrp/bt/revision b/bt5/erp5_mrp/bt/revision
index fefb598af8..9e6181a6ed 100644
--- a/bt5/erp5_mrp/bt/revision
+++ b/bt5/erp5_mrp/bt/revision
@@ -1 +1 @@
-284
\ No newline at end of file
+285
\ No newline at end of file
-- 
2.30.9