From b875e4dc095d6833ad5480643011c3ba6d769c66 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 21 Feb 2019 13:55:11 +0100 Subject: [PATCH] IDEMPIERE-3707 [Info Window] - Default Value for seqNoSelection --- migration/i6.2/oracle/201902211352_IDEMPIERE-3707.sql | 4 ++++ .../i6.2/postgresql/201902211352_IDEMPIERE-3707.sql | 4 ++++ org.adempiere.base/src/org/compiere/model/MColumn.java | 7 +++++++ .../src/org/compiere/model/MInfoColumn.java | 9 +++++++++ 4 files changed, 24 insertions(+) create mode 100644 migration/i6.2/oracle/201902211352_IDEMPIERE-3707.sql create mode 100644 migration/i6.2/postgresql/201902211352_IDEMPIERE-3707.sql diff --git a/migration/i6.2/oracle/201902211352_IDEMPIERE-3707.sql b/migration/i6.2/oracle/201902211352_IDEMPIERE-3707.sql new file mode 100644 index 0000000000..aeb36e2b09 --- /dev/null +++ b/migration/i6.2/oracle/201902211352_IDEMPIERE-3707.sql @@ -0,0 +1,4 @@ +UPDATE AD_Column SET SeqNoSelection=SeqNoSelection*10 WHERE SeqNoSelection>0 AND IsSelectionColumn='Y' AND IsActive='Y'; +SELECT register_migration_script('201902211352_IDEMPIERE-3707.sql') FROM dual +; + diff --git a/migration/i6.2/postgresql/201902211352_IDEMPIERE-3707.sql b/migration/i6.2/postgresql/201902211352_IDEMPIERE-3707.sql new file mode 100644 index 0000000000..aeb36e2b09 --- /dev/null +++ b/migration/i6.2/postgresql/201902211352_IDEMPIERE-3707.sql @@ -0,0 +1,4 @@ +UPDATE AD_Column SET SeqNoSelection=SeqNoSelection*10 WHERE SeqNoSelection>0 AND IsSelectionColumn='Y' AND IsActive='Y'; +SELECT register_migration_script('201902211352_IDEMPIERE-3707.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 b5f6574179..f90633e7d7 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MColumn.java @@ -424,6 +424,13 @@ public class MColumn extends X_AD_Column } } + if (isSelectionColumn() && getSeqNoSelection() <= 0) { + int next = DB.getSQLValueEx(get_TrxName(), + "SELECT ROUND((COALESCE(MAX(SeqNoSelection),0)+10)/10,0)*10 FROM AD_Column WHERE AD_Table_ID=? AND IsSelectionColumn='Y' AND IsActive='Y'", + getAD_Table_ID()); + setSeqNoSelection(next); + } + return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/model/MInfoColumn.java b/org.adempiere.base/src/org/compiere/model/MInfoColumn.java index 9cbf39906b..338707f465 100644 --- a/org.adempiere.base/src/org/compiere/model/MInfoColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MInfoColumn.java @@ -22,6 +22,7 @@ import java.util.logging.Level; import org.adempiere.model.IInfoColumn; import org.compiere.model.AccessSqlParser.TableInfo; +import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Evaluatee; import org.compiere.util.Evaluator; @@ -143,6 +144,14 @@ public class MInfoColumn extends X_AD_InfoColumn implements IInfoColumn M_Element element = new M_Element (getCtx(), getAD_Element_ID (), get_TrxName()); setName (element.getName()); } + + if (isQueryCriteria() && getSeqNoSelection() <= 0) { + int next = DB.getSQLValueEx(get_TrxName(), + "SELECT ROUND((COALESCE(MAX(SeqNoSelection),0)+10)/10,0)*10 FROM AD_InfoColumn WHERE AD_InfoWindow_ID=? AND IsQueryCriteria='Y' AND IsActive='Y'", + getAD_InfoWindow_ID()); + setSeqNoSelection(next); + } + return true; }