From 3bf9012ade4e56bd78a6af6f94b755258c17e30a Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Fri, 13 Aug 2004 09:27:33 +0000
Subject: [PATCH] This function generates "nice" title from the object's id.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1344 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../ERP5/Extensions/FixMissingCategoryTitles.py  | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100755 product/ERP5/Extensions/FixMissingCategoryTitles.py

diff --git a/product/ERP5/Extensions/FixMissingCategoryTitles.py b/product/ERP5/Extensions/FixMissingCategoryTitles.py
new file mode 100755
index 0000000000..03eb207262
--- /dev/null
+++ b/product/ERP5/Extensions/FixMissingCategoryTitles.py
@@ -0,0 +1,16 @@
+import string
+
+def fixMissingCategoryTitles(self):
+  """
+    Recursively sets a default title when it's empty or equal to id
+    Must be called on CategoryTool
+  """
+  for base in self.getChildNodes():
+    objectlist = base.getCategoryChildValueList()
+    for object in objectlist :
+      title = object.getTitle()
+      id = object.getId()
+      if len(title) == 0 or title is None or title == id :
+        new_title = string.capwords(id.replace('_', ' '))
+        setattr(object, 'title', new_title)
+  return 'done'
-- 
2.30.9