From 380a783726eb9a7e11ba643486454a9e2f1e1dec Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Wed, 10 Apr 2013 16:42:45 +0200
Subject: [PATCH] Fix race condition when unlinking simulation movement from
 deleted delivery line

---
 .../scripts/DeliveryMovement_unlinkSimulation.xml           | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/scripts/DeliveryMovement_unlinkSimulation.xml b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/scripts/DeliveryMovement_unlinkSimulation.xml
index 30c8cd845c..d30b51aa4c 100644
--- a/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/scripts/DeliveryMovement_unlinkSimulation.xml
+++ b/bt5/erp5_base/WorkflowTemplateItem/portal_workflow/delivery_movement_simulation_interaction_workflow/scripts/DeliveryMovement_unlinkSimulation.xml
@@ -60,6 +60,12 @@ role, but someday we\'ll have to move this to unrestricted environment.\n
 """\n
 delivery_movement = state_change[\'object\']\n
 \n
+# Always modify movement even if there is no related movement simulation,\n
+# because a concurrent transaction may be linking one to this movement\n
+# (which would modify the local index for "delivery" category).\n
+# In such case, one of the 2 transactions must be restarted.\n
+delivery_movement.serialize()\n
+\n
 # Clean simulation\n
 simulation_movement_list = delivery_movement.getDeliveryRelatedValueList(\n
     portal_type="Simulation Movement")\n
-- 
2.30.9