From 9291a637a9c74641e6ba296162d684f4a40a189b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 1 Feb 2008 10:28:41 +0000 Subject: [PATCH] enable full text search for accounting transactions git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18965 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/AccountingTransaction.py | 16 ++++++++++++++++ product/ERP5/tests/testAccounting.py | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/product/ERP5/Document/AccountingTransaction.py b/product/ERP5/Document/AccountingTransaction.py index ee5764e359..0d89ca456c 100644 --- a/product/ERP5/Document/AccountingTransaction.py +++ b/product/ERP5/Document/AccountingTransaction.py @@ -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 diff --git a/product/ERP5/tests/testAccounting.py b/product/ERP5/tests/testAccounting.py index 930b84e92c..10ba2bae8a 100644 --- a/product/ERP5/tests/testAccounting.py +++ b/product/ERP5/tests/testAccounting.py @@ -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() -- 2.30.9