From e1202b37e0d00df98900a213aa5f39f6997fe4b0 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 7 Oct 2023 03:28:18 +0200 Subject: [PATCH] IDEMPIERE-5567 Support of UUID as Key (FHCA-4195) (#2042) - Fix issue with 2Pack reported by Hiep --- .../src/org/adempiere/pipo2/PoExporter.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java index df2a31c215..a814f34f4a 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java @@ -13,6 +13,7 @@ import org.compiere.model.I_AD_Org; import org.compiere.model.MArchive; import org.compiere.model.MAttachment; import org.compiere.model.MClientInfo; +import org.compiere.model.MColumn; import org.compiere.model.MImage; import org.compiere.model.MStorageProvider; import org.compiere.model.MTable; @@ -270,6 +271,7 @@ public class PoExporter { } int displayType = info.getColumnDisplayType(i); + String trxName = ctx.trx == null ? null : ctx.trx.getTrxName(); if (DisplayType.YesNo == displayType) { add(columnName, false, new AttributesImpl()); } else if (DisplayType.TableDir == displayType || DisplayType.ID == displayType) { @@ -277,17 +279,18 @@ public class PoExporter { if (("Record_ID".equalsIgnoreCase(columnName) || "Record_UU".equalsIgnoreCase(columnName)) && po.get_ColumnIndex("AD_Table_ID") >= 0) { int AD_Table_ID = po.get_ValueAsInt("AD_Table_ID"); if (AD_Table_ID > 0) - tableName = MTable.get(ctx.ctx, AD_Table_ID, ctx.trx.getTrxName()).getTableName(); + tableName = MTable.get(ctx.ctx, AD_Table_ID, trxName).getTableName(); } else if (po.get_TableName().equals("AD_TreeNode") && columnName.equals("Parent_ID")) { int AD_Tree_ID = po.get_ValueAsInt("AD_Tree_ID"); - MTree tree = new MTree(ctx.ctx, AD_Tree_ID, ctx.trx.getTrxName()); + MTree tree = new MTree(ctx.ctx, AD_Tree_ID, trxName); tableName = tree.getSourceTableName(true); } else if (po.get_TableName().equals("AD_TreeNode") && columnName.equals("Node_ID")) { int AD_Tree_ID = po.get_ValueAsInt("AD_Tree_ID"); - MTree tree = new MTree(ctx.ctx, AD_Tree_ID, ctx.trx.getTrxName()); + MTree tree = new MTree(ctx.ctx, AD_Tree_ID, trxName); tableName = tree.getSourceTableName(true); } else { - tableName = columnName.substring(0, columnName.length() - 3); + MColumn column = MColumn.get(ctx.ctx, info.getTableName(), columnName, trxName); + tableName = column.getReferenceTableName(); } addTableReference(columnName, tableName, new AttributesImpl()); } else if (DisplayType.isList(displayType)) { @@ -297,7 +300,7 @@ public class PoExporter { if (("Record_ID".equalsIgnoreCase(columnName) || "Record_UU".equalsIgnoreCase(columnName)) && po.get_ColumnIndex("AD_Table_ID") >= 0) { int AD_Table_ID = po.get_ValueAsInt("AD_Table_ID"); if (AD_Table_ID > 0) - tableName = MTable.get(ctx.ctx, AD_Table_ID, ctx.trx.getTrxName()).getTableName(); + tableName = MTable.get(ctx.ctx, AD_Table_ID, trxName).getTableName(); } else if (info.getColumnLookup(i) != null){ String lookupColumn = info.getColumnLookup(i).getColumnName(); tableName = lookupColumn.substring(0, lookupColumn.indexOf("."));