From f1742db32632a3e4f3b9da56147cdcacc8aae2df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 13 Mar 2013 13:34:04 +0100
Subject: [PATCH] try not to group by uid which has a cost on performance

---
 ...ingTransactionModule_getAccountingTransactionList.xml | 9 ++++++++-
 bt5/erp5_accounting_alternate_catalog/bt/revision        | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/bt5/erp5_accounting_alternate_catalog/SkinTemplateItem/portal_skins/erp5_accounting_alternate_catalog/AccountingTransactionModule_getAccountingTransactionList.xml b/bt5/erp5_accounting_alternate_catalog/SkinTemplateItem/portal_skins/erp5_accounting_alternate_catalog/AccountingTransactionModule_getAccountingTransactionList.xml
index 8cde8517ee..79c21d4499 100644
--- a/bt5/erp5_accounting_alternate_catalog/SkinTemplateItem/portal_skins/erp5_accounting_alternate_catalog/AccountingTransactionModule_getAccountingTransactionList.xml
+++ b/bt5/erp5_accounting_alternate_catalog/SkinTemplateItem/portal_skins/erp5_accounting_alternate_catalog/AccountingTransactionModule_getAccountingTransactionList.xml
@@ -151,7 +151,14 @@ select_dict.update(dict(total_debit=None,\n
                         operation_date=None))\n
 \n
 params[\'select_dict\'] = select_dict\n
-params.setdefault(\'group_by\', (\'uid\',))\n
+\n
+# We group by uid to really filter duplicated lines, but this makes generated\n
+# query much slower, and in reality duplicated lines are transactions for which\n
+# both source section and destination section match the criterions. This can be\n
+# because there are no criterion on section_uid or because both sections are members\n
+# of the selected group. In the later it can be accepted as not a problem.\n
+if not params.get(\'accounting_transaction.section_uid\'):\n
+  params.setdefault(\'group_by\', (\'uid\',))\n
 \n
 return context.searchFolder(**params)\n
 </string> </value>
diff --git a/bt5/erp5_accounting_alternate_catalog/bt/revision b/bt5/erp5_accounting_alternate_catalog/bt/revision
index bf0d87ab1b..7813681f5b 100644
--- a/bt5/erp5_accounting_alternate_catalog/bt/revision
+++ b/bt5/erp5_accounting_alternate_catalog/bt/revision
@@ -1 +1 @@
-4
\ No newline at end of file
+5
\ No newline at end of file
-- 
2.30.9