diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index 1b27fd52f7..7e76257bf7 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -2126,7 +2126,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable if (!canHaveAttachment()) return 0; String recordUU = m_mTable.getKeyUUID(m_currentRow); - return MAttachment.getID(m_vo.AD_Table_ID, recordUU); + int recordID = m_mTable.getKeyID(m_currentRow); + return MAttachment.getID(m_vo.AD_Table_ID, recordID, recordUU); } // getAttachmentID /** @@ -2147,7 +2148,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable if (!canHaveAttachment()) return 0; String recordUU = m_mTable.getKeyUUID(m_currentRow); - return MChat.getID(m_vo.AD_Table_ID, recordUU); + int recordID = m_mTable.getKeyID(m_currentRow); + return MChat.getID(m_vo.AD_Table_ID, recordID, recordUU); } // getCM_ChatID /** @@ -2167,7 +2169,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable if (!canHaveAttachment()) return 0; String recordUU = m_mTable.getKeyUUID(m_currentRow); - return MPostIt.getID(m_vo.AD_Table_ID, recordUU); + int recordID = m_mTable.getKeyID(m_currentRow); + return MPostIt.getID(m_vo.AD_Table_ID, recordID, recordUU); } // getAD_PostIt_ID /** @@ -2178,7 +2181,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable if (!canHaveAttachment()) return false; String recordUU = m_mTable.getKeyUUID(m_currentRow); - return MLabelAssignment.hasAnyAssignment(m_vo.AD_Table_ID, recordUU); + int recordID = m_mTable.getKeyID(m_currentRow); + return MLabelAssignment.hasAnyAssignment(m_vo.AD_Table_ID, recordID, recordUU); } // hasLabel /** diff --git a/org.adempiere.base/src/org/compiere/model/MAttachment.java b/org.adempiere.base/src/org/compiere/model/MAttachment.java index b00083f35d..24a03827a7 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttachment.java +++ b/org.adempiere.base/src/org/compiere/model/MAttachment.java @@ -165,7 +165,7 @@ public class MAttachment extends X_AD_Attachment */ public MAttachment(Properties ctx, int AD_Table_ID, int Record_ID, String Record_UU, String trxName) { - this (ctx, MAttachment.getID(AD_Table_ID, Record_UU) > 0 ? MAttachment.getID(AD_Table_ID, Record_UU) : 0, trxName); + this (ctx, (MAttachment.getID(AD_Table_ID, Record_ID, Record_UU) > 0 ? MAttachment.getID(AD_Table_ID, Record_ID, Record_UU) : 0), trxName); if (get_ID() == 0) { setAD_Table_ID (AD_Table_ID); setRecord_ID (Record_ID); @@ -659,7 +659,7 @@ public class MAttachment extends X_AD_Attachment * @param Table_ID * @param Record_ID * @return AD_Attachment_ID - * @deprecated Use {@link MAttachment#getID(int, String)} instead + * @deprecated Use {@link MAttachment#getID(int, int, String)} instead */ public static int getID(int Table_ID, int Record_ID) { String sql="SELECT AD_Attachment_ID FROM AD_Attachment WHERE AD_Table_ID=? AND Record_ID=?"; @@ -671,10 +671,13 @@ public class MAttachment extends X_AD_Attachment * IDEMPIERE-530 * Get the attachment ID based on table_id and record_uu * @param Table_ID + * @param Record_ID * @param Record_UU record UUID * @return AD_Attachment_ID */ - public static int getID(int Table_ID, String Record_UU) { + public static int getID(int Table_ID, int Record_ID, String Record_UU) { + if (Util.isEmpty(Record_UU)) + return getID(Table_ID, Record_ID); String sql="SELECT AD_Attachment_ID FROM AD_Attachment WHERE AD_Table_ID=? AND Record_UU=?"; int attachid = DB.getSQLValue(null, sql, Table_ID, Record_UU); return attachid; diff --git a/org.adempiere.base/src/org/compiere/model/MChat.java b/org.adempiere.base/src/org/compiere/model/MChat.java index 449c6a8848..a775024404 100644 --- a/org.adempiere.base/src/org/compiere/model/MChat.java +++ b/org.adempiere.base/src/org/compiere/model/MChat.java @@ -227,7 +227,7 @@ public class MChat extends X_CM_Chat * @param Table_ID * @param Record_ID * @return CM_Chat_ID - * @deprecated Use {@link MChat#getID(int, String)} instead + * @deprecated Use {@link MChat#getID(int, int, String)} instead */ public static int getID(int Table_ID, int Record_ID) { String sql="SELECT CM_Chat_ID FROM CM_Chat WHERE AD_Table_ID=? AND Record_ID=?"; @@ -239,9 +239,12 @@ public class MChat extends X_CM_Chat * Get the chat ID based on table_id and record_uu * @param Table_ID * @param Record_UU + * @param Record_ID * @return CM_Chat_ID */ - public static int getID(int Table_ID, String Record_UU) { + public static int getID(int Table_ID, int Record_ID, String Record_UU) { + if (Util.isEmpty(Record_UU)) + return getID(Table_ID, Record_ID); String sql="SELECT CM_Chat_ID FROM CM_Chat WHERE AD_Table_ID=? AND Record_UU=?"; int chatID = DB.getSQLValueEx(null, sql, Table_ID, Record_UU); return chatID; diff --git a/org.adempiere.base/src/org/compiere/model/MLabelAssignment.java b/org.adempiere.base/src/org/compiere/model/MLabelAssignment.java index 5ab3e9991d..3b1f5f6439 100644 --- a/org.adempiere.base/src/org/compiere/model/MLabelAssignment.java +++ b/org.adempiere.base/src/org/compiere/model/MLabelAssignment.java @@ -87,10 +87,13 @@ public class MLabelAssignment extends X_AD_LabelAssignment { /** * Check if record has any label assigned * @param Table_ID + * @param Record_ID * @param Record_UU * @return true if record has any label assigned */ - public static boolean hasAnyAssignment(int Table_ID, String Record_UU) { + public static boolean hasAnyAssignment(int Table_ID, int Record_ID, String Record_UU) { + if (Util.isEmpty(Record_UU)) + return hasAnyAssignment(Table_ID, Record_ID); String sql="SELECT COUNT(*) FROM AD_LabelAssignment WHERE AD_Table_ID=? AND Record_UU=?"; int counter = DB.getSQLValueEx(null, sql, Table_ID, Record_UU); return counter > 0; diff --git a/org.adempiere.base/src/org/compiere/model/MPostIt.java b/org.adempiere.base/src/org/compiere/model/MPostIt.java index f8d7df4109..e61ed84b23 100644 --- a/org.adempiere.base/src/org/compiere/model/MPostIt.java +++ b/org.adempiere.base/src/org/compiere/model/MPostIt.java @@ -128,7 +128,7 @@ public class MPostIt extends X_AD_PostIt * @param Table_ID * @param Record_ID * @return AD_PostIt_ID - * @deprecated Use {@link MPostIt#getID(int, String)} instead + * @deprecated Use {@link MPostIt#getID(int, int, String)} instead */ @Deprecated public static int getID(int Table_ID, int Record_ID) { @@ -139,10 +139,13 @@ public class MPostIt extends X_AD_PostIt /** * @param Table_ID + * @param Record_ID * @param Record_UU * @return AD_PostIt_ID */ - public static int getID(int Table_ID, String Record_UU) { + public static int getID(int Table_ID, int Record_ID, String Record_UU) { + if (Util.isEmpty(Record_UU)) + return getID(Table_ID, Record_ID); String sql="SELECT AD_PostIt_ID FROM AD_PostIt WHERE AD_Table_ID=? AND Record_UU=?"; int postItID = DB.getSQLValueEx(null, sql, Table_ID, Record_UU); return postItID; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LabelsPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LabelsPanel.java index 853aca2c11..c71110f45b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LabelsPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LabelsPanel.java @@ -88,7 +88,13 @@ public class LabelsPanel extends Div implements EventListener { this.abstractADWindowContent = abstractADWindowContent; this.AD_Table_ID = AD_Table_ID; this.Record_ID = Record_ID; - this.Record_UU = Record_UU; + if (Record_ID > 0 && Record_UU == null) { + MTable table = MTable.get(AD_Table_ID); + PO po = table.getPO(Record_ID, null); + this.Record_UU = po.get_UUID(); + } else { + this.Record_UU = Record_UU; + } setStyle("padding:0px 5px;"); addEventListener(LabelsSearchController.ON_POST_SELECT_LABELITEM_EVENT, this); update();