Fixes Issue 0040241:Unpost process can be very slow
authorAtul Gaware <atul.gaware@openbravo.com>
Wed, 20 Feb 2019 09:46:02 +0530
changeset 35325 bf5f0343dba5
parent 35324 e3d66bfad0a5
child 35326 75f6164f8691
Fixes Issue 0040241:Unpost process can be very slow

To use existing index fact_acct_table_record_id for
ad_table_id and record_id columns of fact_acct, ad_table_id
is added in AND clause of exists subquery from fact_acct
table only if record id is sent to getDocbasetypes method.
src/org/openbravo/financial/ResetAccounting.java
--- a/src/org/openbravo/financial/ResetAccounting.java	Wed Feb 13 10:09:43 2019 +0530
+++ b/src/org/openbravo/financial/ResetAccounting.java	Wed Feb 20 09:46:02 2019 +0530
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2013-2018 Openbravo SLU
+ * All portions are Copyright (C) 2013-2019 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -447,7 +447,7 @@
         + " and exists (select 1 from FinancialMgmtAccountingFact e where e.documentCategory=d.documentCategory ";
 
     if (!"".equals(recordId)) {
-      myQuery = myQuery + "and e.recordID=:recordId";
+      myQuery = myQuery + "and e.table.id =:tableId and e.recordID=:recordId";
     }
     myQuery = myQuery + ")";
     Query<String> query = OBDal.getInstance().getSession().createQuery(myQuery, String.class);