diff --git a/migration/i6.2/oracle/201901261333_IDEMPIERE-3509.sql b/migration/i6.2/oracle/201901261333_IDEMPIERE-3509.sql new file mode 100644 index 0000000000..fcdf855fb7 --- /dev/null +++ b/migration/i6.2/oracle/201901261333_IDEMPIERE-3509.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3509:Message about can't find out direct table reference +-- Sep 30, 2017 11:59:56 PM ICT +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Can''''t resolve reference table for column "{0}"',0,0,'Y',TO_DATE('2017-09-30 23:59:55','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2017-09-30 23:59:55','YYYY-MM-DD HH24:MI:SS'),100,200432,'NotReferenceTable','D','4f338d58-5c2d-4dda-8817-93f1954ab4eb') +; + +SELECT register_migration_script('201901261333_IDEMPIERE-3509.sql') FROM dual +; + diff --git a/migration/i6.2/postgresql/201901261333_IDEMPIERE-3509.sql b/migration/i6.2/postgresql/201901261333_IDEMPIERE-3509.sql new file mode 100644 index 0000000000..db51b43c15 --- /dev/null +++ b/migration/i6.2/postgresql/201901261333_IDEMPIERE-3509.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-3509:Message about can't find out direct table reference +-- Sep 30, 2017 11:59:56 PM ICT +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Can''''t resolve reference table for column "{0}"',0,0,'Y',TO_TIMESTAMP('2017-09-30 23:59:55','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2017-09-30 23:59:55','YYYY-MM-DD HH24:MI:SS'),100,200432,'NotReferenceTable','D','4f338d58-5c2d-4dda-8817-93f1954ab4eb') +; + +SELECT register_migration_script('201901261333_IDEMPIERE-3509.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MColumn.java b/org.adempiere.base/src/org/compiere/model/MColumn.java index f7a302758b..7c12a848ec 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MColumn.java @@ -274,7 +274,25 @@ public class MColumn extends X_AD_Column return false; } } - + + if ( displayType == DisplayType.TableDir || + (displayType == DisplayType.Search && getAD_Reference_Value_ID() <= 0)) + { + // verify the foreign table exists + String foreignTableName = getReferenceTableName(); + MTable foreignTable = MTable.get(getCtx(), foreignTableName); + if (foreignTable == null || foreignTable.getAD_Table_ID() <= 0) { + log.saveError("Error", Msg.getMsg(getCtx(), "NotReferenceTable", new Object[] {getColumnName()})); + return false; + } + } + + if (displayType == DisplayType.Table && getAD_Reference_Value_ID() <= 0) + { + log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Reference_Value_ID")); + return false; + } + if (displayType != DisplayType.Button) { if (! ISTOOLBARBUTTON_Window.equals(getIsToolbarButton()))