From c12779c00472f686e6aa84c7cdec3e8c8a663de2 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Mon, 26 Jul 2004 16:41:33 +0000
Subject: [PATCH] try to reindex the object before updating relation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1294 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/skins/erp5_core/base_update_relation.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/skins/erp5_core/base_update_relation.py b/product/ERP5/skins/erp5_core/base_update_relation.py
index 3ffa1bff85..f4af987b41 100755
--- a/product/ERP5/skins/erp5_core/base_update_relation.py
+++ b/product/ERP5/skins/erp5_core/base_update_relation.py
@@ -1,4 +1,4 @@
-##parameters=form_id, selection_index, selection_name, object_uid
+##parameters=form_id, selection_index, selection_name, object_uid, object_path
 
 # Updates attributes of an Zope document
 # which is in a class inheriting from ERP5 Base
@@ -19,7 +19,12 @@ o = context.portal_catalog.getObject(object_uid)
 redirect_url = None
 
 if o is None:
-  return "Sorrry, Error, the calling object was not catalogued. Do not know how to do ?"
+  # we first try to reindex the object, thanks to the object_path
+  o = context.restrictedTraverse(object_path)
+  if o is not None:
+    o.immediateReindexObject()
+  else:
+    return "Sorrry, Error, the calling object was not catalogued. Do not know how to do ?"
 
 def checkSameKeys(a , b):
   """
-- 
2.30.9