From bd991c49ec368c4e0610309d9a8138e30e00d0a9 Mon Sep 17 00:00:00 2001 From: phib Date: Wed, 9 May 2012 16:15:34 -0500 Subject: [PATCH] Copy/create print format items creates duplicate fields. Fixes #50. Integrated to iDempiere by Carlos Ruiz (globalqss) as a partial solution for IDEMPIERE-132 Avoid duplicate in print format http://adempiere.hg.sourceforge.net/hgweb/adempiere/contribution_adaxa/raw-rev/f94eae8928cd --- org.adempiere.base/src/org/compiere/print/MPrintFormat.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java index 79f27acbfd..9ec955b251 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java @@ -597,6 +597,7 @@ public class MPrintFormat extends X_AD_PrintFormat + "FROM AD_Field " + "WHERE AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=?)" + " AND IsEncrypted='N' AND ObscureType IS NULL " + + " AND AD_Column_ID NOT IN (SELECT pfi.AD_Column_ID FROM AD_PrintFormatItem pfi WHERE pfi.AD_PrintFormat_ID=? AND pfi.AD_Column_ID IS NOT NULL) " + "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, SeqNo, Name"; PreparedStatement pstmt = null; ResultSet rs = null; @@ -604,6 +605,7 @@ public class MPrintFormat extends X_AD_PrintFormat { pstmt = DB.prepareStatement(sql, format.get_TrxName()); pstmt.setInt(1, format.getAD_Table_ID()); + pstmt.setInt(2, format.getAD_PrintFormat_ID()); rs = pstmt.executeQuery(); int seqNo = 1; while (rs.next()) @@ -631,11 +633,13 @@ public class MPrintFormat extends X_AD_PrintFormat sql = "SELECT AD_Column_ID " + "FROM AD_Column " + "WHERE AD_Table_ID=? " + + " AND AD_Column_ID NOT IN (SELECT pfi.AD_Column_ID FROM AD_PrintFormatItem pfi WHERE pfi.AD_PrintFormat_ID=? AND pfi.AD_Column_ID IS NOT NULL) " + "ORDER BY IsIdentifier DESC, SeqNo, Name"; try { pstmt = DB.prepareStatement(sql, format.get_TrxName()); pstmt.setInt(1, format.getAD_Table_ID()); + pstmt.setInt(2, format.getAD_PrintFormat_ID()); rs = pstmt.executeQuery(); int seqNo = 1; while (rs.next())