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
This commit is contained in:
phib 2012-05-09 16:15:34 -05:00
parent 162b0becf4
commit bd991c49ec
1 changed files with 4 additions and 0 deletions

View File

@ -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())