From f1b1d1559719729e359a5e72bd262703f84c2df9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Fri, 9 Oct 2009 09:52:47 +0000
Subject: [PATCH]  - close open assignments for person documents when those are
 deleted using workflow action

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29511 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../workflow_chain_type.xml                   |   2 +-
 .../person_interaction_workflow.xml           |  49 +++++++
 .../interactions.xml                          |  31 +++++
 .../onDeleteCloseOpenAssignments.xml          |  94 +++++++++++++
 .../person_interaction_workflow/scripts.xml   |  31 +++++
 .../scripts/closeOpenAssignments.xml          | 129 ++++++++++++++++++
 .../person_interaction_workflow/variables.xml |  25 ++++
 .../person_interaction_workflow/worklists.xml |  25 ++++
 bt5/erp5_base/bt/revision                     |   2 +-
 .../template_portal_type_workflow_chain_list  |   1 +
 bt5/erp5_base/bt/template_workflow_id_list    |   1 +
 11 files changed, 388 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow.xml
 create mode 100644 bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions.xml
 create mode 100644 bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions/onDeleteCloseOpenAssignments.xml
 create mode 100644 bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts.xml
 create mode 100644 bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts/closeOpenAssignments.xml
 create mode 100644 bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/variables.xml
 create mode 100644 bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/worklists.xml

diff --git a/bt5/erp5_base/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/bt5/erp5_base/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
index 5fa2ff0363..7cab2e467d 100644
--- a/bt5/erp5_base/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
+++ b/bt5/erp5_base/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
@@ -69,7 +69,7 @@
  </chain>
  <chain>
   <type>Person</type>
-  <workflow>edit_workflow, user_account_workflow, validation_workflow</workflow>
+  <workflow>edit_workflow, person_interaction_workflow, user_account_workflow, validation_workflow</workflow>
  </chain>
  <chain>
   <type>Property Divergence Tester</type>
diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow.xml
new file mode 100644
index 0000000000..20f688c85d
--- /dev/null
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="InteractionWorkflowDefinition" module="Products.ERP5.InteractionWorkflow"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>creation_guard</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string>Interaction workflow to mostly manage assignments for Persons.</string> </value>
+        </item>
+        <item>
+            <key> <string>groups</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>person_interaction_workflow</string> </value>
+        </item>
+        <item>
+            <key> <string>manager_bypass</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Interaction workflow for Person portal type</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions.xml
new file mode 100644
index 0000000000..6788072919
--- /dev/null
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Interaction" module="Products.ERP5.Interaction"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>interactions</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions/onDeleteCloseOpenAssignments.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions/onDeleteCloseOpenAssignments.xml
new file mode 100644
index 0000000000..da28963e2b
--- /dev/null
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/interactions/onDeleteCloseOpenAssignments.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>actbox_category</string> </key>
+            <value> <string>workflow</string> </value>
+        </item>
+        <item>
+            <key> <string>actbox_name</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>actbox_url</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>activate_script_name</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>after_script_name</string> </key>
+            <value>
+              <list>
+                <string>closeOpenAssignments</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>before_commit_script_name</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>guard</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>onDeleteCloseOpenAssignments</string> </value>
+        </item>
+        <item>
+            <key> <string>method_id</string> </key>
+            <value>
+              <list>
+                <string>delete</string>
+                <string>delete_action</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>once_per_transaction</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>portal_type_filter</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>script_name</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Close started assignments in case of deletion</string> </value>
+        </item>
+        <item>
+            <key> <string>trigger_type</string> </key>
+            <value> <int>2</int> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts.xml
new file mode 100644
index 0000000000..0622b3c34f
--- /dev/null
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Scripts" module="Products.DCWorkflow.Scripts"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>scripts</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts/closeOpenAssignments.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts/closeOpenAssignments.xml
new file mode 100644
index 0000000000..bae6d5e411
--- /dev/null
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/scripts/closeOpenAssignments.xml
@@ -0,0 +1,129 @@
+<?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>Script_magic</string> </key>
+            <value> <int>3</int> </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>person = state_change[\'object\']\n
+for assignment in person.contentValues(portal_type=\'Assignment\'):\n
+  if assignment.getValidationState() == \'open\':\n
+    assignment.close()\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>state_change</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>state_change</string>
+                            <string>_getitem_</string>
+                            <string>person</string>
+                            <string>_getiter_</string>
+                            <string>_getattr_</string>
+                            <string>assignment</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>closeOpenAssignments</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/variables.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/variables.xml
new file mode 100644
index 0000000000..5547232278
--- /dev/null
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/variables.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Variables" module="Products.DCWorkflow.Variables"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>variables</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/worklists.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/worklists.xml
new file mode 100644
index 0000000000..1f8b17b012
--- /dev/null
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/person_interaction_workflow/worklists.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Worklists" module="Products.DCWorkflow.Worklists"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>worklists</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision
index b697ae4122..6f1745c38f 100644
--- a/bt5/erp5_base/bt/revision
+++ b/bt5/erp5_base/bt/revision
@@ -1 +1 @@
-635
\ No newline at end of file
+636
\ No newline at end of file
diff --git a/bt5/erp5_base/bt/template_portal_type_workflow_chain_list b/bt5/erp5_base/bt/template_portal_type_workflow_chain_list
index b2ad47b509..92d16bf344 100644
--- a/bt5/erp5_base/bt/template_portal_type_workflow_chain_list
+++ b/bt5/erp5_base/bt/template_portal_type_workflow_chain_list
@@ -24,6 +24,7 @@ Notification Message | notification_message_workflow
 Organisation | edit_workflow
 Organisation | validation_workflow
 Person | edit_workflow
+Person | person_interaction_workflow
 Person | user_account_workflow
 Person | validation_workflow
 Property Divergence Tester | edit_workflow
diff --git a/bt5/erp5_base/bt/template_workflow_id_list b/bt5/erp5_base/bt/template_workflow_id_list
index eff82d0407..8fba933cc8 100644
--- a/bt5/erp5_base/bt/template_workflow_id_list
+++ b/bt5/erp5_base/bt/template_workflow_id_list
@@ -10,6 +10,7 @@ local_permission_interaction_workflow
 notification_message_workflow
 order_movement_simulation_interaction_workflow
 order_simulation_interaction_workflow
+person_interaction_workflow
 query_workflow
 simulation_movement_causality_interaction_workflow
 user_account_workflow
\ No newline at end of file
-- 
2.30.9