From e2a5b96126b3f709521ed8412fb845461bfd321c Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Wed, 14 Jun 2017 17:24:02 +0800 Subject: [PATCH] IDEMPIERE-3350 Accounting Processor GL postings to "secondary" schema unreliable. MAcctSchema.isSkipOrgs should always check the full org tree. --- .../src/org/compiere/model/MAcctSchema.java | 5 ++--- org.adempiere.base/src/org/compiere/model/MTree.java | 4 +++- .../src/org/compiere/report/MReportTree.java | 11 ++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MAcctSchema.java b/org.adempiere.base/src/org/compiere/model/MAcctSchema.java index 194065c176..1ebe499c42 100644 --- a/org.adempiere.base/src/org/compiere/model/MAcctSchema.java +++ b/org.adempiere.base/src/org/compiere/model/MAcctSchema.java @@ -396,9 +396,8 @@ public class MAcctSchema extends X_C_AcctSchema { if (m_onlyOrgs == null) { - m_onlyOrgs = MReportTree.getChildIDs(getCtx(), - 0, MAcctSchemaElement.ELEMENTTYPE_Organization, - getAD_OrgOnly_ID()); + MReportTree tree = new MReportTree (getCtx(), 0, true, MAcctSchemaElement.ELEMENTTYPE_Organization); + m_onlyOrgs = tree.getChildIDs(getAD_OrgOnly_ID()); } return m_onlyOrgs; } // getOnlyOrgs diff --git a/org.adempiere.base/src/org/compiere/model/MTree.java b/org.adempiere.base/src/org/compiere/model/MTree.java index f24f2d8f5f..0d7af47776 100644 --- a/org.adempiere.base/src/org/compiere/model/MTree.java +++ b/org.adempiere.base/src/org/compiere/model/MTree.java @@ -253,7 +253,9 @@ public class MTree extends MTree_Base if (!m_editable) sql.append(" AND tn.IsActive='Y'"); sql.append(" ORDER BY COALESCE(tn.Parent_ID, -1), tn.SeqNo"); - sql = new StringBuffer(MRole.getDefault().addAccessSQL(sql.toString(), "st", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)); // SQL_RO for Org_ID = 0 + //do not check access if allNodes + if (AD_User_ID != -1) + sql = new StringBuffer(MRole.getDefault().addAccessSQL(sql.toString(), "st", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)); // SQL_RO for Org_ID = 0 } if (log.isLoggable(Level.FINEST)) log.finest(sql.toString()); // The Node Loop diff --git a/org.adempiere.base/src/org/compiere/report/MReportTree.java b/org.adempiere.base/src/org/compiere/report/MReportTree.java index 2dcc96a4fc..307891c84b 100644 --- a/org.adempiere.base/src/org/compiere/report/MReportTree.java +++ b/org.adempiere.base/src/org/compiere/report/MReportTree.java @@ -100,14 +100,19 @@ public class MReportTree /** Map with Tree */ private static CCache s_trees = new CCache(null, "MReportTree", 20, false); - + public MReportTree (Properties ctx, int PA_Hierarchy_ID, String ElementType) + { + this(ctx, PA_Hierarchy_ID, false, ElementType); + } + /************************************************************************** * Report Tree * @param ctx context * @param PA_Hierarchy_ID optional hierarchy + * @param allNodes true to always get full tree * @param ElementType Account Schema Element Type */ - public MReportTree (Properties ctx, int PA_Hierarchy_ID, String ElementType) + public MReportTree (Properties ctx, int PA_Hierarchy_ID, boolean allNodes, String ElementType) { m_ElementType = ElementType; m_TreeType = m_ElementType; @@ -127,7 +132,7 @@ public class MReportTree + ", PA_Hierarchy_ID=" + PA_Hierarchy_ID); // boolean clientTree = true; - m_tree = new MTree (ctx, AD_Tree_ID, true, clientTree, null); // include inactive and empty summary nodes + m_tree = new MTree (ctx, AD_Tree_ID, true, clientTree, allNodes, null); // include inactive and empty summary nodes // remove summary nodes without children m_tree.trimTree(); } // MReportTree