IDEMPIERE-3509 NPE when csv export order with "Sales Representative" / add validations to avoid wrong column definition

This commit is contained in:
Carlos Ruiz 2019-01-26 13:43:35 +01:00
parent 42f0399bae
commit 926fe806f8
3 changed files with 38 additions and 1 deletions

View File

@ -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
;

View File

@ -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
;

View File

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