From 7843c00a1c25165f61de65d95162271275f55136 Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Tue, 6 Nov 2007 16:29:33 +0000
Subject: [PATCH] alex: changes to support new style Rules

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17420 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../portal_rules/default_delivery_rule.xml    |  16 ++
 .../portal_rules/default_order_rule.xml       |  16 ++
 .../workflow_chain_type.xml                   |   4 +-
 .../DeliveryRule_testContextPortalType.xml    | 147 ++++++++++++++++++
 .../OrderRule_testContextPortalType.xml       | 147 ++++++++++++++++++
 bt5/erp5_trade/bt/revision                    |   2 +-
 .../template_portal_type_workflow_chain_list  |   2 +
 7 files changed, 331 insertions(+), 3 deletions(-)
 create mode 100644 bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryRule_testContextPortalType.xml
 create mode 100644 bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderRule_testContextPortalType.xml

diff --git a/bt5/erp5_trade/PathTemplateItem/portal_rules/default_delivery_rule.xml b/bt5/erp5_trade/PathTemplateItem/portal_rules/default_delivery_rule.xml
index e5b6313216..2629cd3dfc 100644
--- a/bt5/erp5_trade/PathTemplateItem/portal_rules/default_delivery_rule.xml
+++ b/bt5/erp5_trade/PathTemplateItem/portal_rules/default_delivery_rule.xml
@@ -39,6 +39,10 @@
               <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
             </value>
         </item>
+        <item>
+            <key> <string>default_reference</string> </key>
+            <value> <string>default_delivery_rule</string> </value>
+        </item>
         <item>
             <key> <string>id</string> </key>
             <value> <string>default_delivery_rule</string> </value>
@@ -47,6 +51,14 @@
             <key> <string>portal_type</string> </key>
             <value> <string>Delivery Rule</string> </value>
         </item>
+        <item>
+            <key> <string>test_method_id</string> </key>
+            <value>
+              <tuple>
+                <string>DeliveryRule_testContextPortalType</string>
+              </tuple>
+            </value>
+        </item>
         <item>
             <key> <string>title</string> </key>
             <value> <string>Default Delivery Rule</string> </value>
@@ -57,6 +69,10 @@
               <none/>
             </value>
         </item>
+        <item>
+            <key> <string>version</string> </key>
+            <value> <string>1</string> </value>
+        </item>
       </dictionary>
     </pickle>
   </record>
diff --git a/bt5/erp5_trade/PathTemplateItem/portal_rules/default_order_rule.xml b/bt5/erp5_trade/PathTemplateItem/portal_rules/default_order_rule.xml
index 1f55e70112..8bea35069e 100644
--- a/bt5/erp5_trade/PathTemplateItem/portal_rules/default_order_rule.xml
+++ b/bt5/erp5_trade/PathTemplateItem/portal_rules/default_order_rule.xml
@@ -39,6 +39,10 @@
               <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
             </value>
         </item>
+        <item>
+            <key> <string>default_reference</string> </key>
+            <value> <string>default_order_rule</string> </value>
+        </item>
         <item>
             <key> <string>id</string> </key>
             <value> <string>default_order_rule</string> </value>
@@ -47,6 +51,14 @@
             <key> <string>portal_type</string> </key>
             <value> <string>Order Rule</string> </value>
         </item>
+        <item>
+            <key> <string>test_method_id</string> </key>
+            <value>
+              <tuple>
+                <string>OrderRule_testContextPortalType</string>
+              </tuple>
+            </value>
+        </item>
         <item>
             <key> <string>title</string> </key>
             <value> <string>Default Order Rule</string> </value>
@@ -57,6 +69,10 @@
               <none/>
             </value>
         </item>
+        <item>
+            <key> <string>version</string> </key>
+            <value> <string>1</string> </value>
+        </item>
       </dictionary>
     </pickle>
   </record>
diff --git a/bt5/erp5_trade/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/bt5/erp5_trade/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
index 76602ed192..0bf4276bfe 100644
--- a/bt5/erp5_trade/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
+++ b/bt5/erp5_trade/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
@@ -17,7 +17,7 @@
  </chain>
  <chain>
   <type>Delivery Rule</type>
-  <workflow>edit_workflow</workflow>
+  <workflow>edit_workflow, rule_validation_workflow</workflow>
  </chain>
  <chain>
   <type>Discount</type>
@@ -41,7 +41,7 @@
  </chain>
  <chain>
   <type>Order Rule</type>
-  <workflow>edit_workflow</workflow>
+  <workflow>edit_workflow, rule_validation_workflow</workflow>
  </chain>
  <chain>
   <type>Payment Condition</type>
diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryRule_testContextPortalType.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryRule_testContextPortalType.xml
new file mode 100644
index 0000000000..f3bb2aac9f
--- /dev/null
+++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryRule_testContextPortalType.xml
@@ -0,0 +1,147 @@
+<?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>return context.getPortalType() in [\'Sale Packing List\']\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>rule</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>rule</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>DeliveryRule_testContextPortalType</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderRule_testContextPortalType.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderRule_testContextPortalType.xml
new file mode 100644
index 0000000000..bf63e0abe5
--- /dev/null
+++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderRule_testContextPortalType.xml
@@ -0,0 +1,147 @@
+<?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>return context.getPortalType() in [\'Sale Order\']\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>rule</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>rule</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>OrderRule_testContextPortalType</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade/bt/revision b/bt5/erp5_trade/bt/revision
index b5db9c417a..83248fb9df 100644
--- a/bt5/erp5_trade/bt/revision
+++ b/bt5/erp5_trade/bt/revision
@@ -1 +1 @@
-139
\ No newline at end of file
+142
\ No newline at end of file
diff --git a/bt5/erp5_trade/bt/template_portal_type_workflow_chain_list b/bt5/erp5_trade/bt/template_portal_type_workflow_chain_list
index 7bab95bbdc..9826aaf716 100644
--- a/bt5/erp5_trade/bt/template_portal_type_workflow_chain_list
+++ b/bt5/erp5_trade/bt/template_portal_type_workflow_chain_list
@@ -9,6 +9,7 @@ Container | pricing_interaction_workflow
 Delivery Cell | delivery_movement_causality_interaction_workflow
 Delivery Cell | delivery_movement_simulation_interaction_workflow
 Delivery Rule | edit_workflow
+Delivery Rule | rule_validation_workflow
 Discount | edit_workflow
 Internal Packing List Line | edit_workflow
 Internal Packing List Line | pricing_interaction_workflow
@@ -21,6 +22,7 @@ Inventory Line | trade_matrix_workflow
 Inventory | edit_workflow
 Inventory | inventory_workflow
 Order Rule | edit_workflow
+Order Rule | rule_validation_workflow
 Payment Condition | edit_workflow
 Purchase Order Cell | edit_workflow
 Purchase Order Cell | order_movement_simulation_interaction_workflow
-- 
2.30.9