From 53ef632eccdadf1610a680c205b503ad1ae55068 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 9 Jul 2021 11:50:34 +0200 Subject: [PATCH] IDEMPIERE-1026 Button on table to create automatically the window (#775) * IDEMPIERE-1026 Button on table to create automatically the window Set relevant fields for translation tabs * Set better order by for translation tables * Minor performance fix found when testing this - the callout is visiting the database even on null column --- .../src/org/compiere/model/Callout_AD_Column.java | 2 ++ .../src/org/compiere/process/CreateWindowFromTable.java | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/Callout_AD_Column.java b/org.adempiere.base.callout/src/org/compiere/model/Callout_AD_Column.java index c2da07bb6a..c69d0fa698 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/Callout_AD_Column.java +++ b/org.adempiere.base.callout/src/org/compiere/model/Callout_AD_Column.java @@ -31,6 +31,8 @@ public class Callout_AD_Column extends CalloutEngine { public String columnName (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) { // IDEMPIERE-1011 - dup code on MColumn.setmartDefaults + if (value == null) + return ""; I_AD_Column column = GridTabWrapper.create(mTab, I_AD_Column.class); if (MColumn.isSuggestSelectionColumn(column.getColumnName(), true)) column.setIsSelectionColumn(true); diff --git a/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java b/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java index ca603d8c1d..ca6628ea84 100644 --- a/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java +++ b/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java @@ -180,7 +180,7 @@ public class CreateWindowFromTable extends SvrProcess tab.setAD_Table_ID(p_AD_Table_ID); tab.setTabLevel(p_TabLevel); tab.setIsSingleRow(true); //Default - + //Set order by if (table.columnExistsInDB("Value")) tab.setOrderByClause(table.getTableName() + ".Value"); @@ -189,6 +189,13 @@ public class CreateWindowFromTable extends SvrProcess else tab.setOrderByClause(table.getTableName() + ".Created DESC"); + if (table.getTableName().toLowerCase().endsWith("_trl")) { + tab.setIsTranslationTab(true); + tab.setIsInsertRecord(false); + if (table.columnExistsInDB("AD_Language")) + tab.setOrderByClause(table.getTableName() + ".AD_Language"); + } + tab.saveEx(); addLog(tab.getAD_Tab_ID(), null, null, "@AD_Tab_ID@: " + tab.getName(), tab.get_Table_ID(), tab.getAD_Tab_ID());