From faee590479b8f3d87d0655463a80b7e7a23e40fa Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Fri, 12 Apr 2013 16:57:07 +0200
Subject: [PATCH] Fix useless expand after delivery building

This fixes a performance regression introduced in
commit 0a8fbb3656455cc20255f77771317608dc65d4be
("Simulation: index 'delivery' categories in ZODB")

Built delivery lines are modified by newContent(), before
SimulatedDeliveryBuilder._setDeliveryMovementProperties() has a chance to set
the delivery link on the related simulation movement.
So isGeneratedBySimulation() always returned False.

One solution was to revert all changes in
  product/ERP5/Document/Movement.py
  product/ERP5/Document/SimulatedDeliveryBuilder.py
from the aforementioned commit, but it's much simpler to move the interaction
at the end of the transaction, even if in some rare cases, 2 '_updateSimulation'
activities are created, causing a slight overhead on activity tool.

Signed-off-by: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
---
 .../interactions/update_simulation.xml                    | 8 ++++----
 bt5/erp5_base/bt/revision                                 | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/interactions/update_simulation.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/interactions/update_simulation.xml
index 8f6ee2bbd6..1ccced5895 100644
--- a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/interactions/update_simulation.xml
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/interactions/update_simulation.xml
@@ -27,15 +27,15 @@
         <item>
             <key> <string>after_script_name</string> </key>
             <value>
-              <list>
-                <string>DeliveryMovement_updateSimulation</string>
-              </list>
+              <tuple/>
             </value>
         </item>
         <item>
             <key> <string>before_commit_script_name</string> </key>
             <value>
-              <tuple/>
+              <list>
+                <string>DeliveryMovement_updateSimulation</string>
+              </list>
             </value>
         </item>
         <item>
diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision
index a89dec1731..09fef806d9 100644
--- a/bt5/erp5_base/bt/revision
+++ b/bt5/erp5_base/bt/revision
@@ -1 +1 @@
-1034
\ No newline at end of file
+1035
\ No newline at end of file
-- 
2.30.9