Commit 9291a637 authored by Jérome Perrin's avatar Jérome Perrin

enable full text search for accounting transactions


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18965 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 357f5896
......@@ -97,6 +97,22 @@ class AccountingTransaction(Delivery):
return section.isMemberOf(preferred_section_category)
return 0
def SearchableText(self):
"""Text for full text search"""
text_list = []
for prop in ( self.getTitle(),
self.getDescription(),
self.getComment(),
self.getReference(),
self.getSourceReference(),
self.getDestinationReference(),
self.getSourceSectionTitle(),
self.getDestinationSectionTitle(),
self.getStartDate(),
self.getStopDate(), ):
if prop:
text_list.append(prop)
return ' '.join(text_list)
# Compatibility
# It may be necessary to create an alias after removing the Transaction class
......
......@@ -2985,6 +2985,16 @@ class TestAccounting(ERP5TypeTestCase):
self.assertEquals('2002-1', next_year_transaction.getSourceReference())
self.assertEquals('2002-1', next_year_transaction.getDestinationReference())
def test_SearchableText(self):
transaction = self.createAccountingTransaction(
title='A new Transaction',
description="A description",
comment="Some comments")
searchable_text = transaction.SearchableText()
self.assertTrue('A new Transaction' in searchable_text)
self.assertTrue('A description' in searchable_text)
self.assertTrue('Some comments' in searchable_text)
def test_suite():
suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment