diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py index cb7f2259878cbd703c4a5f9444c317d839ab8d17..24d9c9df56b4654ec7506960f82cc4948f8fa6d0 100644 --- a/product/ERP5OOo/tests/testDms.py +++ b/product/ERP5OOo/tests/testDms.py @@ -892,6 +892,19 @@ class TestDocument(TestDocumentMixin): web_page.getReference(), web_page.getLanguage(), web_page.getVersion()))) + + document = portal.document_module.newContent( + portal_type = 'Presentation',) + # searchable text is empty by default + self.assertEquals('', document.SearchableText()) + # it contains title + document.setTitle('foo') + self.assertEquals('foo', document.SearchableText()) + # and description + document.setDescription('bar') + self.assertTrue('bar' in document.SearchableText(), + document.SearchableText()) + def test_10_SearchString(self): """ Test search string search generation and parsing. diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 2863db6b2ab9cf91ee1d144bae7e4f04fded529c..3dae23ce742579475b029d354fbb70283fd1047b 100644 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -3020,10 +3020,13 @@ class Base( CopyContainer, # so use definition of 'Base Type' for searchable methods & properties portal_type = self.portal_types.getTypeInfo('Base Type') searchable_text_method_id_list = [] + # generated from properties methods and add explicitly defined method_ids as well for searchable_text_property_id in portal_type.getSearchableTextPropertyIdList(): - method_id = convertToUpperCase(searchable_text_property_id) - searchable_text_method_id_list.extend(['get%s' %method_id]) + if self.hasProperty(searchable_text_property_id): + method_id = convertToUpperCase(searchable_text_property_id) + searchable_text_method_id_list.extend(['get%s' %method_id]) + searchable_text_method_id_list.extend(portal_type.getSearchableTextMethodIdList()) for method_id in searchable_text_method_id_list: # XXX: how to exclude exclude acquisition (not working) @@ -3039,7 +3042,7 @@ class Base( CopyContainer, else: searchable_text_list.append(method_value) searchable_text = ' '.join([str(x) for x in searchable_text_list]) - return searchable_text + return searchable_text.strip() # Compatibility with CMF Catalog / CPS sites SearchableText = getSearchableText