From c8fd9a88053686be3303a201cf681af71232a565 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 16 Mar 2021 10:03:40 +0100 Subject: [PATCH] IDEMPIERE-4736 FHCA-2461 IDEMP - ad_column table - Framework query improvement (#628) * IDEMPIERE-4736 FHCA-2461 IDEMP - ad_column table - Framework query improvement * * Rename migration scripts to normal convention --- migration/i8.2/oracle/202103091322_IDEMPIERE-4736.sql | 10 ++++++++++ .../i8.2/postgresql/202103091322_IDEMPIERE-4736.sql | 7 +++++++ org.adempiere.base/src/org/compiere/model/MRole.java | 2 +- org.adempiere.base/src/org/compiere/util/Login.java | 2 +- .../src/org/adempiere/webui/panel/RolePanel.java | 6 +++--- 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 migration/i8.2/oracle/202103091322_IDEMPIERE-4736.sql create mode 100644 migration/i8.2/postgresql/202103091322_IDEMPIERE-4736.sql diff --git a/migration/i8.2/oracle/202103091322_IDEMPIERE-4736.sql b/migration/i8.2/oracle/202103091322_IDEMPIERE-4736.sql new file mode 100644 index 0000000000..08fea0eea7 --- /dev/null +++ b/migration/i8.2/oracle/202103091322_IDEMPIERE-4736.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Mar 9, 2021, 1:20:04 PM CET +UPDATE AD_Ref_Table SET WhereClause='AD_Table.IsView=''N'' AND AD_Table.IsActive=''Y'' AND EXISTS (SELECT 1 FROM AD_Column c WHERE c.AD_Table_ID=AD_Table.AD_Table_ID AND UPPER(c.ColumnName)=UPPER(AD_Table.TableName)||''_ID'' AND c.IsActive=''Y'')',Updated=TO_DATE('2021-03-09 13:20:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200165 +; + +SELECT register_migration_script('202103091322_IDEMPIERE-4736.sql') FROM dual +; + diff --git a/migration/i8.2/postgresql/202103091322_IDEMPIERE-4736.sql b/migration/i8.2/postgresql/202103091322_IDEMPIERE-4736.sql new file mode 100644 index 0000000000..26e6f74913 --- /dev/null +++ b/migration/i8.2/postgresql/202103091322_IDEMPIERE-4736.sql @@ -0,0 +1,7 @@ +-- Mar 9, 2021, 1:20:04 PM CET +UPDATE AD_Ref_Table SET WhereClause='AD_Table.IsView=''N'' AND AD_Table.IsActive=''Y'' AND EXISTS (SELECT 1 FROM AD_Column c WHERE c.AD_Table_ID=AD_Table.AD_Table_ID AND UPPER(c.ColumnName)=UPPER(AD_Table.TableName)||''_ID'' AND c.IsActive=''Y'')',Updated=TO_TIMESTAMP('2021-03-09 13:20:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200165 +; + +SELECT register_migration_script('202103091322_IDEMPIERE-4736.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MRole.java b/org.adempiere.base/src/org/compiere/model/MRole.java index 7efcbc2943..ecae07aaa5 100644 --- a/org.adempiere.base/src/org/compiere/model/MRole.java +++ b/org.adempiere.base/src/org/compiere/model/MRole.java @@ -972,7 +972,7 @@ public final class MRole extends X_AD_Role implements ImmutablePOSupport PreparedStatement pstmt = null; ResultSet rs = null; String sql = "SELECT AD_Table_ID, AccessLevel, TableName, IsView, " - + "(SELECT ColumnName FROM AD_COLUMN WHERE AD_COLUMN.AD_TABLE_ID = AD_TABLE.AD_TABLE_ID AND AD_COLUMN.COLUMNNAME = AD_TABLE.TABLENAME || '_ID') " + + "(SELECT ColumnName FROM AD_COLUMN WHERE AD_COLUMN.AD_TABLE_ID = AD_TABLE.AD_TABLE_ID AND UPPER(AD_COLUMN.COLUMNNAME) = UPPER(AD_TABLE.TABLENAME) || '_ID') " + "FROM AD_Table WHERE IsActive='Y'"; try { diff --git a/org.adempiere.base/src/org/compiere/util/Login.java b/org.adempiere.base/src/org/compiere/util/Login.java index 9abd6b2755..0925e745d6 100644 --- a/org.adempiere.base/src/org/compiere/util/Login.java +++ b/org.adempiere.base/src/org/compiere/util/Login.java @@ -840,7 +840,7 @@ public class Login Ini.setProperty(Ini.P_PRINTER, printerName); // Load Role Info - MRole.getDefault(m_ctx, true); + MRole.getDefault(m_ctx, false); // Other loadUserPreferences(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java index a405669eab..fb11139ae4 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java @@ -686,9 +686,9 @@ public class RolePanel extends Window implements EventListener, Deferrabl userPreference.setProperty(UserPreference.P_WAREHOUSE, lstItemWarehouse != null ? (String) lstItemWarehouse.getValue() : "0"); userPreference.savePreference(); - //force reload of default role - MRole.getDefault(m_ctx, true); - + //force reload of default role when more than 1 client + if (lstClient.getChildren().size() > 1) + MRole.getDefault(m_ctx, true); // }