From a9d7783d01e6ced613eaeac0a0c29524d0b851e8 Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Tue, 2 Oct 2007 12:29:31 +0000
Subject: [PATCH] * push production_packing_list_causality_workflow to the same
 level as packing_list_causality_workflow * add causality interaction
 workflows to workflow chains of production related deliveries

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16776 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../workflow_chain_type.xml                   |  16 +-
 ...uction_packing_list_causality_workflow.xml |   2 +-
 .../scripts/PackingList_acceptDecision.xml    |   2 +-
 .../scripts/PackingList_adoptPrevision.xml    |   2 +-
 .../scripts/PackingList_afterEdit.xml         | 148 ++++++++++++++++++
 .../scripts/PackingList_split.xml             |  14 +-
 .../states/building.xml                       |  85 ++++++++++
 .../states/calculating.xml                    | 116 ++++++++++++++
 .../states/diverged.xml                       |  71 ++++++++-
 .../states/draft.xml                          | 106 +++++++++++++
 .../states/solved.xml                         |  71 ++++++++-
 .../states/solving.xml                        |  85 ++++++++++
 .../transitions/accept_decision.xml           |   2 +-
 .../transitions/adopt_prevision.xml           |   8 +-
 .../transitions/calculate.xml                 |  70 +++++++++
 .../transitions/converge.xml                  |  44 +-----
 .../transitions/diverge.xml                   |  44 +-----
 .../transitions/split_prevision.xml           |   4 +-
 .../transitions/split_prevision_action.xml    |   4 +-
 .../{edit.xml => start_building.xml}          |   4 +-
 bt5/erp5_mrp/bt/revision                      |   2 +-
 .../template_portal_type_workflow_chain_list  |   6 +
 22 files changed, 796 insertions(+), 110 deletions(-)
 create mode 100644 bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_afterEdit.xml
 create mode 100644 bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/building.xml
 create mode 100644 bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/calculating.xml
 create mode 100644 bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/draft.xml
 create mode 100644 bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solving.xml
 create mode 100644 bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/calculate.xml
 rename bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/{edit.xml => start_building.xml} (94%)

diff --git a/bt5/erp5_mrp/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/bt5/erp5_mrp/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
index c8c6734ee1..e6244e3a90 100644
--- a/bt5/erp5_mrp/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
+++ b/bt5/erp5_mrp/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
@@ -17,19 +17,27 @@
  </chain>
  <chain>
   <type>Production Packing List</type>
-  <workflow>production_packing_list_workflow, production_packing_list_causality_workflow, edit_workflow, production_packing_list_interaction_workflow</workflow>
+  <workflow>production_packing_list_workflow, production_packing_list_causality_workflow, edit_workflow, production_packing_list_interaction_workflow, delivery_causality_interaction_workflow</workflow>
+ </chain>
+ <chain>
+  <type>Production Packing List Cell</type>
+  <workflow>delivery_movement_causality_interaction_workflow</workflow>
  </chain>
  <chain>
   <type>Production Packing List Line</type>
-  <workflow>edit_workflow, production_packing_list_interaction_workflow, production_matrix_workflow</workflow>
+  <workflow>delivery_movement_causality_interaction_workflow, edit_workflow, production_packing_list_interaction_workflow, production_matrix_workflow</workflow>
  </chain>
  <chain>
   <type>Production Report</type>
-  <workflow>production_packing_list_causality_workflow, production_packing_list_interaction_workflow, edit_workflow, production_packing_list_workflow</workflow>
+  <workflow>production_packing_list_causality_workflow, production_packing_list_interaction_workflow, edit_workflow, production_packing_list_workflow, delivery_causality_interaction_workflow</workflow>
+ </chain>
+ <chain>
+  <type>Production Report Cell</type>
+  <workflow>delivery_movement_causality_interaction_workflow</workflow>
  </chain>
  <chain>
   <type>Production Report Line</type>
-  <workflow>edit_workflow, production_matrix_workflow, production_packing_list_interaction_workflow</workflow>
+  <workflow>delivery_movement_causality_interaction_workflow, edit_workflow, production_matrix_workflow, production_packing_list_interaction_workflow</workflow>
  </chain>
  <chain>
   <type>Supply Chain</type>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow.xml
index 10d4101ec4..a7f724d81a 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow.xml
@@ -42,7 +42,7 @@
         </item>
         <item>
             <key> <string>initial_state</string> </key>
-            <value> <string>solved</string> </value>
+            <value> <string>draft</string> </value>
         </item>
         <item>
             <key> <string>permissions</string> </key>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_acceptDecision.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_acceptDecision.xml
index 48cb9f432b..4f442833da 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_acceptDecision.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_acceptDecision.xml
@@ -81,7 +81,7 @@ packing_list.portal_simulation.solveDelivery(packing_list, None,\n
                                              "CopyToTarget")\n
 \n
 # Automatic workflow\n
-packing_list.edit()\n
+packing_list.activate().updateCausalityState()\n
 </string> </value>
         </item>
         <item>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_adoptPrevision.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_adoptPrevision.xml
index 118c9e0ad7..d8424f96cc 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_adoptPrevision.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_adoptPrevision.xml
@@ -87,7 +87,7 @@ packing_list_relative_url = packing_list.getRelativeUrl()\n
 delivery_builder.updateFromSimulation(packing_list_relative_url)\n
 \n
 # Automatic workflow\n
-packing_list.edit()\n
+packing_list.activate().updateCausalityState()\n
 </string> </value>
         </item>
         <item>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_afterEdit.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_afterEdit.xml
new file mode 100644
index 0000000000..4f7f1e7fd0
--- /dev/null
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_afterEdit.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.PythonScripts.PythonScript</string>
+          <string>PythonScript</string>
+        </tuple>
+        <none/>
+      </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>context = state_change[\'object\']\n
+if context.getSimulationState()!=\'draft\':\n
+  context.activate().updateCausalityState()\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>_params</string> </key>
+            <value> <string>state_change,**kw</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>kw</string>
+                            <string>_getitem_</string>
+                            <string>context</string>
+                            <string>_getattr_</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>PackingList_afterEdit</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_split.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_split.xml
index 2dab0abff4..b879e4703e 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_split.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/scripts/PackingList_split.xml
@@ -80,13 +80,15 @@ packing_list.updateAppliedRule()\n
 \n
 # We do not use DeliverySolver, because, by default, we keep delivery_ratio\n
 # untouch\n
+tag = packing_list.getPath() + \'_split\'\n
 packing_list.portal_simulation.solveDelivery(packing_list, None, \n
                                              "SplitAndDefer",\n
                                              start_date=start_date,\n
-                                             stop_date=stop_date)\n
+                                             stop_date=stop_date,\n
+                                             activate_kw={\'tag\':tag})\n
 \n
 # Automatic workflow\n
-packing_list.edit()\n
+packing_list.activate().updateCausalityState()\n
 \n
 # Create delivery\n
 order = packing_list.getCausalityValue()\n
@@ -100,8 +102,9 @@ if order_portal_type == \'Sale Order\':\n
 elif order_portal_type == \'Purchase Order\':\n
   delivery_builder = order.portal_deliveries.purchase_packing_list_builder\n
 \n
-applied_rule_uid = applied_rule.getUid()\n
-delivery_builder.activate().build(applied_rule_uid=applied_rule_uid)\n
+\n
+explanation_uid_list = [order.getUid(),packing_list.getUid()]\n
+delivery_builder.activate(activity=\'SQLQueue\',after_tag=tag).build(explanation_uid=explanation_uid_list)\n
 </string> </value>
         </item>
         <item>
@@ -150,12 +153,13 @@ delivery_builder.activate().build(applied_rule_uid=applied_rule_uid)\n
                             <string>_getattr_</string>
                             <string>stop_date</string>
                             <string>start_date</string>
+                            <string>tag</string>
                             <string>None</string>
                             <string>order</string>
                             <string>applied_rule</string>
                             <string>order_portal_type</string>
                             <string>delivery_builder</string>
-                            <string>applied_rule_uid</string>
+                            <string>explanation_uid_list</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/building.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/building.xml
new file mode 100644
index 0000000000..ca35fe88d6
--- /dev/null
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/building.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.DCWorkflow.States</string>
+          <string>StateDefinition</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>building</string> </value>
+        </item>
+        <item>
+            <key> <string>permission_roles</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Building</string> </value>
+        </item>
+        <item>
+            <key> <string>transitions</string> </key>
+            <value>
+              <tuple>
+                <string>converge</string>
+                <string>diverge</string>
+              </tuple>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Persistence</string>
+          <string>PersistentMapping</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_container</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>Add portal content</string> </key>
+                    <value>
+                      <tuple/>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>Modify portal content</string> </key>
+                    <value>
+                      <tuple/>
+                    </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/calculating.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/calculating.xml
new file mode 100644
index 0000000000..2c8c208d16
--- /dev/null
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/calculating.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.DCWorkflow.States</string>
+          <string>StateDefinition</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>calculating</string> </value>
+        </item>
+        <item>
+            <key> <string>permission_roles</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Calculating</string> </value>
+        </item>
+        <item>
+            <key> <string>transitions</string> </key>
+            <value>
+              <tuple>
+                <string>accept_decision</string>
+                <string>accept_decision_action</string>
+                <string>adopt_prevision</string>
+                <string>adopt_prevision_action</string>
+                <string>converge</string>
+                <string>diverge</string>
+                <string>split_prevision</string>
+                <string>split_prevision_action</string>
+                <string>start_building</string>
+              </tuple>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Persistence</string>
+          <string>PersistentMapping</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_container</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>Add portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Anonymous</string>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>Modify portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Anonymous</string>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/diverged.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/diverged.xml
index a24a0e8b56..9211c88914 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/diverged.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/diverged.xml
@@ -26,6 +26,12 @@
             <key> <string>id</string> </key>
             <value> <string>diverged</string> </value>
         </item>
+        <item>
+            <key> <string>permission_roles</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
         <item>
             <key> <string>title</string> </key>
             <value> <string>Diverged</string> </value>
@@ -38,13 +44,76 @@
                 <string>accept_decision_action</string>
                 <string>adopt_prevision</string>
                 <string>adopt_prevision_action</string>
+                <string>calculate</string>
                 <string>converge</string>
-                <string>edit</string>
                 <string>split_prevision</string>
                 <string>split_prevision_action</string>
+                <string>start_building</string>
               </tuple>
             </value>
         </item>
+        <item>
+            <key> <string>type_list</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Persistence</string>
+          <string>PersistentMapping</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_container</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>Add portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>Modify portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
       </dictionary>
     </pickle>
   </record>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/draft.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/draft.xml
new file mode 100644
index 0000000000..5a7fd7ac60
--- /dev/null
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/draft.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.DCWorkflow.States</string>
+          <string>StateDefinition</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>draft</string> </value>
+        </item>
+        <item>
+            <key> <string>permission_roles</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Draft</string> </value>
+        </item>
+        <item>
+            <key> <string>transitions</string> </key>
+            <value>
+              <tuple>
+                <string>start_building</string>
+              </tuple>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Persistence</string>
+          <string>PersistentMapping</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_container</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>Add portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>Modify portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solved.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solved.xml
index eac0553da3..cca08f364f 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solved.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solved.xml
@@ -26,6 +26,12 @@
             <key> <string>id</string> </key>
             <value> <string>solved</string> </value>
         </item>
+        <item>
+            <key> <string>permission_roles</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
         <item>
             <key> <string>title</string> </key>
             <value> <string>Solved</string> </value>
@@ -34,11 +40,74 @@
             <key> <string>transitions</string> </key>
             <value>
               <tuple>
+                <string>calculate</string>
                 <string>diverge</string>
-                <string>edit</string>
+                <string>start_building</string>
               </tuple>
             </value>
         </item>
+        <item>
+            <key> <string>type_list</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Persistence</string>
+          <string>PersistentMapping</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_container</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>Add portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>Modify portal content</string> </key>
+                    <value>
+                      <list>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Associate</string>
+                        <string>Auditor</string>
+                        <string>Authenticated</string>
+                        <string>Author</string>
+                        <string>Manager</string>
+                        <string>Member</string>
+                        <string>Owner</string>
+                        <string>Reviewer</string>
+                      </list>
+                    </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
       </dictionary>
     </pickle>
   </record>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solving.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solving.xml
new file mode 100644
index 0000000000..df1264240f
--- /dev/null
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/states/solving.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.DCWorkflow.States</string>
+          <string>StateDefinition</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>solving</string> </value>
+        </item>
+        <item>
+            <key> <string>permission_roles</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Solving</string> </value>
+        </item>
+        <item>
+            <key> <string>transitions</string> </key>
+            <value>
+              <tuple>
+                <string>converge</string>
+                <string>diverge</string>
+              </tuple>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Persistence</string>
+          <string>PersistentMapping</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_container</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>Add portal content</string> </key>
+                    <value>
+                      <tuple/>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>Modify portal content</string> </key>
+                    <value>
+                      <tuple/>
+                    </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/accept_decision.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/accept_decision.xml
index f6edf2610a..b2edb445a0 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/accept_decision.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/accept_decision.xml
@@ -50,7 +50,7 @@
         </item>
         <item>
             <key> <string>new_state_id</string> </key>
-            <value> <string></string> </value>
+            <value> <string>solving</string> </value>
         </item>
         <item>
             <key> <string>script_name</string> </key>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/adopt_prevision.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/adopt_prevision.xml
index babe1ef1b4..79b1a1a22d 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/adopt_prevision.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/adopt_prevision.xml
@@ -32,11 +32,11 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>PackingList_adoptPrevision</string> </value>
+            <value> <string></string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
-            <value> <string></string> </value>
+            <value> <string>Set the script before because after the transition we have no right to change the packing list</string> </value>
         </item>
         <item>
             <key> <string>guard</string> </key>
@@ -50,11 +50,11 @@
         </item>
         <item>
             <key> <string>new_state_id</string> </key>
-            <value> <string></string> </value>
+            <value> <string>solving</string> </value>
         </item>
         <item>
             <key> <string>script_name</string> </key>
-            <value> <string></string> </value>
+            <value> <string>PackingList_adoptPrevision</string> </value>
         </item>
         <item>
             <key> <string>title</string> </key>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/calculate.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/calculate.xml
new file mode 100644
index 0000000000..81bbc505c3
--- /dev/null
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/calculate.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.DCWorkflow.Transitions</string>
+          <string>TransitionDefinition</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <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>after_script_name</string> </key>
+            <value> <string>PackingList_afterEdit</string> </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>calculate</string> </value>
+        </item>
+        <item>
+            <key> <string>new_state_id</string> </key>
+            <value> <string>calculating</string> </value>
+        </item>
+        <item>
+            <key> <string>script_name</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></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_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/converge.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/converge.xml
index 3ab212b80c..389c4d21c1 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/converge.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/converge.xml
@@ -41,7 +41,7 @@
         <item>
             <key> <string>guard</string> </key>
             <value>
-              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+              <none/>
             </value>
         </item>
         <item>
@@ -62,47 +62,7 @@
         </item>
         <item>
             <key> <string>trigger_type</string> </key>
-            <value> <int>0</int> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-  <record id="2" aka="AAAAAAAAAAI=">
-    <pickle>
-      <tuple>
-        <tuple>
-          <string>Products.DCWorkflow.Guard</string>
-          <string>Guard</string>
-        </tuple>
-        <none/>
-      </tuple>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>expr</string> </key>
-            <value>
-              <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
-            </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-  <record id="3" aka="AAAAAAAAAAM=">
-    <pickle>
-      <tuple>
-        <tuple>
-          <string>Products.CMFCore.Expression</string>
-          <string>Expression</string>
-        </tuple>
-        <none/>
-      </tuple>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>text</string> </key>
-            <value> <string>here/isConvergent</string> </value>
+            <value> <int>2</int> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/diverge.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/diverge.xml
index 01761d8557..12a504b498 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/diverge.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/diverge.xml
@@ -41,7 +41,7 @@
         <item>
             <key> <string>guard</string> </key>
             <value>
-              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+              <none/>
             </value>
         </item>
         <item>
@@ -62,47 +62,7 @@
         </item>
         <item>
             <key> <string>trigger_type</string> </key>
-            <value> <int>0</int> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-  <record id="2" aka="AAAAAAAAAAI=">
-    <pickle>
-      <tuple>
-        <tuple>
-          <string>Products.DCWorkflow.Guard</string>
-          <string>Guard</string>
-        </tuple>
-        <none/>
-      </tuple>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>expr</string> </key>
-            <value>
-              <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
-            </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-  <record id="3" aka="AAAAAAAAAAM=">
-    <pickle>
-      <tuple>
-        <tuple>
-          <string>Products.CMFCore.Expression</string>
-          <string>Expression</string>
-        </tuple>
-        <none/>
-      </tuple>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>text</string> </key>
-            <value> <string>here/isDivergent</string> </value>
+            <value> <int>2</int> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision.xml
index 351f982544..d4738e9429 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision.xml
@@ -50,7 +50,7 @@
         </item>
         <item>
             <key> <string>new_state_id</string> </key>
-            <value> <string></string> </value>
+            <value> <string>solving</string> </value>
         </item>
         <item>
             <key> <string>script_name</string> </key>
@@ -62,7 +62,7 @@
         </item>
         <item>
             <key> <string>trigger_type</string> </key>
-            <value> <int>2</int> </value>
+            <value> <int>1</int> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision_action.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision_action.xml
index dd636ee109..39466caa9f 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision_action.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/split_prevision_action.xml
@@ -24,7 +24,7 @@
         </item>
         <item>
             <key> <string>actbox_name</string> </key>
-            <value> <string>Split prevision</string> </value>
+            <value> <string>Split and Defer</string> </value>
         </item>
         <item>
             <key> <string>actbox_url</string> </key>
@@ -32,7 +32,7 @@
         </item>
         <item>
             <key> <string>after_script_name</string> </key>
-            <value> <string>PackingList_split</string> </value>
+            <value> <string>PackingList_callSplitPrevisionTransition</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
diff --git a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/edit.xml b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/start_building.xml
similarity index 94%
rename from bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/edit.xml
rename to bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/start_building.xml
index fdf1c0ef63..7638b58a62 100644
--- a/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/edit.xml
+++ b/bt5/erp5_mrp/WorkflowTemplateItem/portal_workflow/production_packing_list_causality_workflow/transitions/start_building.xml
@@ -46,11 +46,11 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>edit</string> </value>
+            <value> <string>start_building</string> </value>
         </item>
         <item>
             <key> <string>new_state_id</string> </key>
-            <value> <string></string> </value>
+            <value> <string>building</string> </value>
         </item>
         <item>
             <key> <string>script_name</string> </key>
diff --git a/bt5/erp5_mrp/bt/revision b/bt5/erp5_mrp/bt/revision
index 7c091989d0..72f523f36e 100644
--- a/bt5/erp5_mrp/bt/revision
+++ b/bt5/erp5_mrp/bt/revision
@@ -1 +1 @@
-37
\ No newline at end of file
+39
\ No newline at end of file
diff --git a/bt5/erp5_mrp/bt/template_portal_type_workflow_chain_list b/bt5/erp5_mrp/bt/template_portal_type_workflow_chain_list
index 411b25ad94..71aea890c3 100644
--- a/bt5/erp5_mrp/bt/template_portal_type_workflow_chain_list
+++ b/bt5/erp5_mrp/bt/template_portal_type_workflow_chain_list
@@ -7,16 +7,22 @@ Production Order Rule | edit_workflow
 Production Order | edit_workflow
 Production Order | order_simulation_interaction_workflow
 Production Order | production_order_workflow
+Production Packing List Cell | delivery_movement_causality_interaction_workflow
+Production Packing List Line | delivery_movement_causality_interaction_workflow
 Production Packing List Line | edit_workflow
 Production Packing List Line | production_matrix_workflow
 Production Packing List Line | production_packing_list_interaction_workflow
+Production Packing List | delivery_causality_interaction_workflow
 Production Packing List | edit_workflow
 Production Packing List | production_packing_list_causality_workflow
 Production Packing List | production_packing_list_interaction_workflow
 Production Packing List | production_packing_list_workflow
+Production Report Cell | delivery_movement_causality_interaction_workflow
+Production Report Line | delivery_movement_causality_interaction_workflow
 Production Report Line | edit_workflow
 Production Report Line | production_matrix_workflow
 Production Report Line | production_packing_list_interaction_workflow
+Production Report | delivery_causality_interaction_workflow
 Production Report | edit_workflow
 Production Report | production_packing_list_causality_workflow
 Production Report | production_packing_list_interaction_workflow
-- 
2.30.9