diff --git a/migration/360lts-release/oracle/897_IDEMPIERE-63.sql b/migration/360lts-release/oracle/897_IDEMPIERE-63.sql new file mode 100644 index 0000000000..9ce01aeaba --- /dev/null +++ b/migration/360lts-release/oracle/897_IDEMPIERE-63.sql @@ -0,0 +1,26 @@ +-- Aug 29, 2012 6:44:34 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Document type cannot be changed when overwrite document number on complete is set and the document was already processed',200025,'D','1bc9f344-4855-473d-a058-424dfd6d9a1e','CannotChangeProcessedDocType','Y',TO_DATE('2012-08-29 18:44:33','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-08-29 18:44:33','YYYY-MM-DD HH24:MI:SS')) +; + +-- Aug 29, 2012 6:44:34 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200025 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Aug 29, 2012 6:44:57 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Date cannot be changed when overwrite date on complete is set and the document was already processed',200026,'D','81bf5a40-ae47-4dcf-9be3-9d04d0c9116f','CannotChangeProcessedDate','Y',TO_DATE('2012-08-29 18:44:56','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-08-29 18:44:56','YYYY-MM-DD HH24:MI:SS')) +; + +-- Aug 29, 2012 6:44:57 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200026 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +UPDATE AD_System + SET LastMigrationScriptApplied='897_IDEMPIERE-63.sql' +WHERE LastMigrationScriptApplied<'897_IDEMPIERE-63.sql' + OR LastMigrationScriptApplied IS NULL +; + diff --git a/migration/360lts-release/postgresql/897_IDEMPIERE-63.sql b/migration/360lts-release/postgresql/897_IDEMPIERE-63.sql new file mode 100644 index 0000000000..74a35bd628 --- /dev/null +++ b/migration/360lts-release/postgresql/897_IDEMPIERE-63.sql @@ -0,0 +1,26 @@ +-- Aug 29, 2012 6:44:34 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Document type cannot be changed when overwrite document number on complete is set and the document was already processed',200025,'D','1bc9f344-4855-473d-a058-424dfd6d9a1e','CannotChangeProcessedDocType','Y',TO_TIMESTAMP('2012-08-29 18:44:33','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-08-29 18:44:33','YYYY-MM-DD HH24:MI:SS')) +; + +-- Aug 29, 2012 6:44:34 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200025 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Aug 29, 2012 6:44:57 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Date cannot be changed when overwrite date on complete is set and the document was already processed',200026,'D','81bf5a40-ae47-4dcf-9be3-9d04d0c9116f','CannotChangeProcessedDate','Y',TO_TIMESTAMP('2012-08-29 18:44:56','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-08-29 18:44:56','YYYY-MM-DD HH24:MI:SS')) +; + +-- Aug 29, 2012 6:44:57 PM COT +-- IDEMPIERE-63 Document number is updated again when document completed after reactivation +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200026 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +UPDATE AD_System + SET LastMigrationScriptApplied='897_IDEMPIERE-63.sql' +WHERE LastMigrationScriptApplied<'897_IDEMPIERE-63.sql' + OR LastMigrationScriptApplied IS NULL +; + diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportBPartner.java b/org.adempiere.base.process/src/org/compiere/process/ImportBPartner.java index 55b575e4df..be27f2c990 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportBPartner.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportBPartner.java @@ -254,7 +254,8 @@ implements ImportProcess + " AND (i.City=l.City OR (i.City IS NULL AND l.City IS NULL))" + " AND (i.Postal=l.Postal OR (i.Postal IS NULL AND l.Postal IS NULL))" + " AND (i.Postal_Add=l.Postal_Add OR (l.Postal_Add IS NULL AND l.Postal_Add IS NULL))" - + " AND i.C_Region_ID=l.C_Region_ID AND i.C_Country_ID=l.C_Country_ID) " + + " AND (i.C_Region_ID=l.C_Region_ID OR (l.C_Region_ID IS NULL AND i.C_Region_ID IS NULL))" + + " AND i.C_Country_ID=l.C_Country_ID) " + "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL" + " AND I_IsImported='N'").append(clientCheck); no = DB.executeUpdateEx(sql.toString(), get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java index 79967a8746..78d5f0d1e5 100644 --- a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java @@ -332,6 +332,11 @@ public class GridFieldVO implements Serializable // Genied: For a range parameter the second field // lookup behaviour should match the first one. voT.AD_Reference_Value_ID = voF.AD_Reference_Value_ID; + // IDEMPIERE-229 Bug with Process parameter range + voT.ValidationCode = voF.ValidationCode; + voT.IsEncryptedField = voF.IsEncryptedField; + voT.ReadOnlyLogic = voF.ReadOnlyLogic; + voT.DisplayLogic = voF.DisplayLogic; voT.initFinish(); return voT; diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 85ec95e9c6..6dae4b1338 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -304,6 +304,28 @@ public class MJournal extends X_GL_Journal implements DocAction } if (getDateAcct() == null) setDateAcct(getDateDoc()); + + // IDEMPIERE-63 + // for documents that can be reactivated we cannot allow changing + // C_DocTypeTarget_ID or C_DocType_ID if they were already processed and isOverwriteSeqOnComplete + // neither change the Date if isOverwriteDateOnComplete + BigDecimal previousProcessedOn = (BigDecimal) get_ValueOld(COLUMNNAME_ProcessedOn); + if (! newRecord && previousProcessedOn != null && previousProcessedOn.signum() > 0) { + int previousDocTypeID = (Integer) get_ValueOld(COLUMNNAME_C_DocType_ID); + MDocType previousdt = MDocType.get(getCtx(), previousDocTypeID); + if (is_ValueChanged(COLUMNNAME_C_DocType_ID)) { + if (previousdt.isOverwriteSeqOnComplete()) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangeProcessedDocType")); + return false; + } + } + if (is_ValueChanged(COLUMNNAME_DateDoc)) { + if (previousdt.isOverwriteDateOnComplete()) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangeProcessedDate")); + return false; + } + } + } // Update DateAcct on lines - teo_sarca BF [ 1775358 ] if (is_ValueChanged(COLUMNNAME_DateAcct)) { @@ -601,12 +623,16 @@ public class MJournal extends X_GL_Journal implements DocAction private void setDefiniteDocumentNo() { MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { - setDateDoc(new Timestamp (System.currentTimeMillis())); + if (this.getProcessedOn().signum() == 0) { + setDateDoc(new Timestamp (System.currentTimeMillis())); + } } if (dt.isOverwriteSeqOnComplete()) { - String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); - if (value != null) - setDocumentNo(value); + if (this.getProcessedOn().signum() == 0) { + String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); + if (value != null) + setDocumentNo(value); + } } } diff --git a/org.adempiere.base/src/org/compiere/model/MLanguage.java b/org.adempiere.base/src/org/compiere/model/MLanguage.java index 9ed15c0d5f..74e80d7a1e 100644 --- a/org.adempiere.base/src/org/compiere/model/MLanguage.java +++ b/org.adempiere.base/src/org/compiere/model/MLanguage.java @@ -28,6 +28,7 @@ import java.util.Properties; import java.util.logging.Level; import org.adempiere.exceptions.DBException; +import org.adempiere.process.UUIDGenerator; import org.compiere.Adempiere; import org.compiere.util.DB; import org.compiere.util.Env; @@ -433,6 +434,12 @@ public class MLanguage extends X_AD_Language // + " WHERE (" + keyColumn + ",'" + getAD_Language()+ "') NOT IN (SELECT " // + keyColumn + ",AD_Language FROM " + tableName + ")"; int no = DB.executeUpdateEx(insert, null, get_TrxName()); + // IDEMPIERE-99 Language Maintenance does not create UUIDs + MTable table = MTable.get(getCtx(), tableName); + MColumn column = table.getColumn(PO.getUUIDColumnName(tableName)); + if (column != null) + UUIDGenerator.updateUUID(column, get_TrxName()); + // log.fine(tableName + " #" + no); return no; } // addTable diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index b546366066..ef0a4e1368 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -1043,6 +1043,28 @@ public class MOrder extends X_C_Order implements DocAction setC_PaymentTerm_ID (ii); } } + + // IDEMPIERE-63 + // for documents that can be reactivated we cannot allow changing + // C_DocTypeTarget_ID or C_DocType_ID if they were already processed and isOverwriteSeqOnComplete + // neither change the Date if isOverwriteDateOnComplete + BigDecimal previousProcessedOn = (BigDecimal) get_ValueOld(COLUMNNAME_ProcessedOn); + if (! newRecord && previousProcessedOn != null && previousProcessedOn.signum() > 0) { + int previousDocTypeID = (Integer) get_ValueOld(COLUMNNAME_C_DocTypeTarget_ID); + MDocType previousdt = MDocType.get(getCtx(), previousDocTypeID); + if (is_ValueChanged(COLUMNNAME_C_DocType_ID) || is_ValueChanged(COLUMNNAME_C_DocTypeTarget_ID)) { + if (previousdt.isOverwriteSeqOnComplete()) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangeProcessedDocType")); + return false; + } + } + if (is_ValueChanged(COLUMNNAME_DateOrdered)) { + if (previousdt.isOverwriteDateOnComplete()) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangeProcessedDate")); + return false; + } + } + } return true; } // beforeSave @@ -1857,13 +1879,13 @@ public class MOrder extends X_C_Order implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { /* a42niem - BF IDEMPIERE-63 - check if document has been completed before */ - if (this.getProcessedOn().compareTo(Env.ZERO) == 0) { + if (this.getProcessedOn().signum() == 0) { setDateOrdered(new Timestamp (System.currentTimeMillis())); } } if (dt.isOverwriteSeqOnComplete()) { /* a42niem - BF IDEMPIERE-63 - check if document has been completed before */ - if (this.getProcessedOn().compareTo(Env.ZERO) == 0) { + if (this.getProcessedOn().signum() == 0) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); if (value != null) setDocumentNo(value); diff --git a/org.adempiere.base/src/org/compiere/model/MRMALine.java b/org.adempiere.base/src/org/compiere/model/MRMALine.java index f763b8cdf0..ee0d46469e 100644 --- a/org.adempiere.base/src/org/compiere/model/MRMALine.java +++ b/org.adempiere.base/src/org/compiere/model/MRMALine.java @@ -170,7 +170,7 @@ public class MRMALine extends X_M_RMALine { int invoiceLine_ID = new Query(getCtx(), I_C_InvoiceLine.Table_Name, "M_InOutLine_ID=?", get_TrxName()) .setParameters(getM_InOutLine_ID()) - .firstIdOnly(); + .firstId(); return invoiceLine_ID <= 0 ? 0 : invoiceLine_ID; } diff --git a/org.adempiere.base/src/org/compiere/model/MTax.java b/org.adempiere.base/src/org/compiere/model/MTax.java index 8c257dc708..4abaca8f8e 100644 --- a/org.adempiere.base/src/org/compiere/model/MTax.java +++ b/org.adempiere.base/src/org/compiere/model/MTax.java @@ -71,7 +71,7 @@ public class MTax extends X_C_Tax //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 List list = new Query(ctx, I_C_Tax.Table_Name, null, null) .setClient_ID() - .setOrderBy("C_Country_ID, C_Region_ID, To_Country_ID, To_Region_ID") + .setOrderBy("C_Country_ID, C_Region_ID, To_Country_ID, To_Region_ID, ValidFrom DESC") .setOnlyActiveRecords(true) .list(); for (MTax tax : list) diff --git a/org.adempiere.base/src/org/compiere/model/MTree.java b/org.adempiere.base/src/org/compiere/model/MTree.java index 8ca2f8aef0..d4e1bab415 100644 --- a/org.adempiere.base/src/org/compiere/model/MTree.java +++ b/org.adempiere.base/src/org/compiere/model/MTree.java @@ -195,19 +195,35 @@ public class MTree extends MTree_Base private void loadNodes (int AD_User_ID) { // SQL for TreeNodes - StringBuffer sql = new StringBuffer("SELECT " - + "tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive " - + "FROM ").append(getNodeTableName()).append(" tn" - + " LEFT OUTER JOIN AD_TreeBar tb ON (tn.AD_Tree_ID=tb.AD_Tree_ID" - + " AND tn.Node_ID=tb.Node_ID " - + (AD_User_ID != -1 ? " AND tb.AD_User_ID=? ": "") // #1 (conditional) - + ") " - + "WHERE tn.AD_Tree_ID=?"); // #2 - if (!m_editable) - sql.append(" AND tn.IsActive='Y'"); - sql.append(" ORDER BY COALESCE(tn.Parent_ID, -1), tn.SeqNo"); + StringBuffer sql = new StringBuffer(); + if (getTreeType().equals(TREETYPE_Menu)) // specific sql, need to load TreeBar IDEMPIERE 329 - nmicoud + { + sql = new StringBuffer("SELECT " + + "tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive " + + "FROM ").append(getNodeTableName()).append(" tn" + + " LEFT OUTER JOIN AD_TreeBar tb ON (tn.AD_Tree_ID=tb.AD_Tree_ID" + + " AND tn.Node_ID=tb.Node_ID " + + (AD_User_ID != -1 ? " AND tb.AD_User_ID=? ": "") // #1 (conditional) + + ") " + + "WHERE tn.AD_Tree_ID=?"); // #2 + if (!m_editable) + sql.append(" AND tn.IsActive='Y'"); + sql.append(" ORDER BY COALESCE(tn.Parent_ID, -1), tn.SeqNo"); + } + else // IDEMPIERE 329 - nmicoud + { + String sourceTableName = getSourceTableName(getTreeType()); + sql = new StringBuffer("SELECT " + + "tn.Node_ID,tn.Parent_ID,tn.SeqNo,st.IsActive " + + "FROM ").append(sourceTableName).append(" st " + + "LEFT OUTER JOIN ").append(getNodeTableName()).append(" tn ON (tn.Node_ID=st."+sourceTableName+"_ID) " + + "WHERE tn.AD_Tree_ID=?"); // #2 + if (!m_editable) + sql.append(" AND tn.IsActive='Y'"); + sql.append(" ORDER BY COALESCE(tn.Parent_ID, -1), tn.SeqNo"); + sql = new StringBuffer(MRole.getDefault().addAccessSQL(sql.toString(), "st", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO)); // SQL_RO for Org_ID = 0 + } log.finest(sql.toString()); - // The Node Loop try { @@ -216,7 +232,7 @@ public class MTree extends MTree_Base // PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); int idx = 1; - if (AD_User_ID != -1) + if (AD_User_ID != -1 && getTreeType().equals(TREETYPE_Menu)) // IDEMPIERE 329 - nmicoud pstmt.setInt(idx++, AD_User_ID); pstmt.setInt(idx++, getAD_Tree_ID()); // Get Tree & Bar diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index fac45bc018..26932d469c 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -1267,8 +1267,9 @@ public abstract class PO log.finest("ID=" + ID); if (ID > 0) { + setKeyInfo(); m_IDs = new Object[] {new Integer(ID)}; - m_KeyColumns = new String[] {p_info.getTableName() + "_ID"}; + //m_KeyColumns = new String[] {p_info.getTableName() + "_ID"}; load(trxName); } else // new @@ -3044,7 +3045,8 @@ public abstract class PO // Carlos Ruiz - globalqss - IDEMPIERE-111 // Check if the role has access to this client - if (!MRole.getDefault().isClientAccess(getAD_Client_ID(), true)) + // Don't check role System as webstore works with this role - see IDEMPIERE-401 + if ((Env.getAD_Role_ID(getCtx()) != 0) && !MRole.getDefault().isClientAccess(getAD_Client_ID(), true)) { log.warning("You cannot delete this record, role doesn't have access"); log.saveError("AccessCannotDelete", "", false); diff --git a/org.adempiere.base/src/org/compiere/report/FinReport.java b/org.adempiere.base/src/org/compiere/report/FinReport.java index 6126746a10..46886a790c 100644 --- a/org.adempiere.base/src/org/compiere/report/FinReport.java +++ b/org.adempiere.base/src/org/compiere/report/FinReport.java @@ -16,6 +16,8 @@ *****************************************************************************/ package org.compiere.report; +import static org.compiere.model.SystemIDs.TABLE_T_REPORT; + import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -25,7 +27,6 @@ import java.util.logging.Level; import org.compiere.model.MAcctSchemaElement; import org.compiere.model.MReportCube; -import static org.compiere.model.SystemIDs.*; import org.compiere.print.MPrintFormat; import org.compiere.print.MPrintFormatItem; import org.compiere.process.ProcessInfoParameter; @@ -1093,6 +1094,7 @@ public class FinReport extends SvrProcess String s = m_report.getWhereClause(); if (s != null && s.length() > 0) insert.append(" AND ").append(s); + insert.append(m_parameterWhere); // IDEMPIERE-130 // Period restriction FinReportPeriod frp = getPeriod (0); insert.append(" AND TRUNC(DateAcct) ") diff --git a/org.adempiere.base/src/org/compiere/tools/FileUtil.java b/org.adempiere.base/src/org/compiere/tools/FileUtil.java index 0d06f2a055..20f49d3ee3 100644 --- a/org.adempiere.base/src/org/compiere/tools/FileUtil.java +++ b/org.adempiere.base/src/org/compiere/tools/FileUtil.java @@ -23,6 +23,8 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.FilenameFilter; import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Calendar; import org.compiere.util.Util; @@ -418,4 +420,15 @@ public class FileUtil new FileUtil(directory, filter, action, from, to); } // main + public static String getTempMailName(String subject, String extension) { + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String dt = sdf.format(cal.getTime()); + String cleanName = subject.replaceAll("[ &/]", ""); + String localFile = System.getProperty("java.io.tmpdir") + + System.getProperty("file.separator") + cleanName + "_" + dt + + extension; + return localFile; + } + } // FileUtil diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index 39417ddaee..f47e9d104d 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -1328,9 +1328,22 @@ public final class Env token = inStr.substring(0, j); + // IDEMPIERE-194 Handling null context variable + String defaultV = null; + int idx = token.indexOf(":"); // or clause + if (idx >= 0) + { + defaultV = token.substring(idx+1, token.length()); + token = token.substring(0, idx); + } + String ctxInfo = getContext(ctx, WindowNo, token, onlyWindow); // get context if (ctxInfo.length() == 0 && (token.startsWith("#") || token.startsWith("$")) ) ctxInfo = getContext(ctx, token); // get global context + + if (ctxInfo.length() == 0 && defaultV != null) + ctxInfo = defaultV; + if (ctxInfo.length() == 0) { getLogger().config("No Context Win=" + WindowNo + " for: " + token); diff --git a/org.adempiere.install/install.app.launch b/org.adempiere.install/install.app.launch index 13ba2d1018..2825f83ab9 100644 --- a/org.adempiere.install/install.app.launch +++ b/org.adempiere.install/install.app.launch @@ -16,7 +16,7 @@ - + diff --git a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportViewer.java b/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportViewer.java index 587692ec25..b1163107c3 100644 --- a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportViewer.java +++ b/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportViewer.java @@ -24,6 +24,7 @@ import net.sf.jasperreports.view.JRViewer; import org.compiere.apps.EMailDialog; import org.compiere.model.MUser; +import org.compiere.tools.FileUtil; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -136,7 +137,7 @@ class SendByEmailListener implements ActionListener { try { - attachment = File.createTempFile("mail", ".pdf"); + attachment = new File(FileUtil.getTempMailName(subject, ".pdf")); JasperExportManager.exportReportToPdfFile(viewer.getJasperPrint(), attachment.getAbsolutePath()); } catch (Exception e) diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDialog.java index 23b2d9ead9..353f758fb3 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDialog.java @@ -14,13 +14,10 @@ package org.compiere.grid; import java.awt.BorderLayout; -import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; import javax.swing.JScrollPane; -import javax.swing.KeyStroke; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; @@ -31,9 +28,11 @@ import org.compiere.apps.AppsAction; import org.compiere.apps.ConfirmPanel; import org.compiere.apps.StatusBar; import org.compiere.minigrid.MiniTable; -import org.compiere.swing.CButton; import org.compiere.swing.CDialog; import org.compiere.swing.CPanel; +import org.compiere.swing.CToggleButton; +import org.compiere.util.Env; +import org.compiere.util.Msg; import org.compiere.util.Trx; import org.compiere.util.TrxRunnable; @@ -49,7 +48,8 @@ public class VCreateFromDialog extends CDialog implements ActionListener, TableM private StatusBar statusBar = new StatusBar(); private MiniTable dataTable = new MiniTable(); - private static final String SELECT_ALL = "SelectAll"; + private static final String SELECT_DESELECT_ALL = "SelectAll"; + protected AppsAction selectDeselectAllAction = new AppsAction (SELECT_DESELECT_ALL, null, Msg.getMsg(Env.getCtx(), SELECT_DESELECT_ALL), true); public VCreateFromDialog(CreateFrom createFrom, int windowNo, boolean modal) { @@ -80,13 +80,11 @@ public class VCreateFromDialog extends CDialog implements ActionListener, TableM JScrollPane dataPane = new JScrollPane(); getContentPane().add(dataPane, BorderLayout.CENTER); dataPane.getViewport().add(dataTable, null); - - AppsAction selectAllAction = new AppsAction (SELECT_ALL, KeyStroke.getKeyStroke(KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK), null); - CButton selectAllButton = (CButton)selectAllAction.getButton(); - selectAllButton.setMargin(new Insets (0, 10, 0, 10)); - selectAllButton.setDefaultCapable(true); - selectAllButton.addActionListener(this); - confirmPanel.addButton(selectAllButton); + + CToggleButton selectAllButton = (CToggleButton)selectDeselectAllAction.getButton(); + selectAllButton.setMargin(ConfirmPanel.s_insets); + selectAllButton.addActionListener(this); + confirmPanel.addComponent(selectAllButton); CPanel southPanel = new CPanel(); getContentPane().add(southPanel, BorderLayout.SOUTH); @@ -125,14 +123,19 @@ public class VCreateFromDialog extends CDialog implements ActionListener, TableM } // Select All // Trifon - else if (e.getActionCommand().equals(SELECT_ALL)) + else if (e.getActionCommand().equals(SELECT_DESELECT_ALL)) { TableModel model = dataTable.getModel(); + model.removeTableModelListener(this); + + // select or deselect all as required int rows = model.getRowCount(); + Boolean selectAll = selectDeselectAllAction.isPressed() ? Boolean.FALSE : Boolean.TRUE; for (int i = 0; i < rows; i++) - { - model.setValueAt(new Boolean(true), i, 0); - } + model.setValueAt(selectAll, i, 0); + + model.addTableModelListener(this); + info(); } } @@ -157,6 +160,22 @@ public class VCreateFromDialog extends CDialog implements ActionListener, TableM type = e.getType(); if (type != TableModelEvent.UPDATE) return; + + if (e.getColumn() == 0) + { + TableModel model = dataTable.getModel(); + Boolean isPressed = (Boolean)model.getValueAt(0, 0); + int rows = model.getRowCount(); + boolean equals = true; + for (int i = 1; equals && i < rows; i++) + { + equals = isPressed.equals(model.getValueAt(i, 0)); + } + + if (equals) { + selectDeselectAllAction.setPressed(isPressed); + } + } } info(); dataTable.repaint(); diff --git a/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java b/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java index 6f2aeac6bd..09edc4e2df 100644 --- a/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java +++ b/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java @@ -18,6 +18,8 @@ *****************************************************************************/ package org.compiere.print; +import static org.compiere.model.SystemIDs.WINDOW_PRINTFORMAT; + import java.awt.BorderLayout; import java.awt.Component; import java.awt.Cursor; @@ -39,6 +41,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Calendar; import java.util.Properties; import java.util.logging.Level; @@ -80,7 +83,6 @@ import org.compiere.model.MQuery; import org.compiere.model.MRole; import org.compiere.model.MUser; import org.compiere.model.PrintInfo; -import static org.compiere.model.SystemIDs.*; import org.compiere.model.X_C_Invoice; import org.compiere.swing.CButton; import org.compiere.swing.CCheckBox; @@ -89,6 +91,7 @@ import org.compiere.swing.CFrame; import org.compiere.swing.CLabel; import org.compiere.swing.CMenuItem; import org.compiere.swing.CPanel; +import org.compiere.tools.FileUtil; import org.compiere.util.CLogMgt; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -99,6 +102,7 @@ import org.compiere.util.Language; import org.compiere.util.Login; import org.compiere.util.Msg; import org.compiere.util.NamePair; +import org.compiere.util.TimeUtil; import org.compiere.util.ValueNamePair; /** @@ -911,7 +915,7 @@ public class Viewer extends CFrame try { - attachment = File.createTempFile("mail", ".pdf"); + attachment = new File(FileUtil.getTempMailName(subject, ".pdf")); m_reportEngine.getPDF(attachment); } catch (Exception e) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java index 2a6ad14b87..2b2ba2a794 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java @@ -46,6 +46,7 @@ import org.compiere.process.ProcessInfo; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.zkoss.zul.Div; import org.zkoss.zul.Hbox; import org.zkoss.zul.Label; @@ -359,21 +360,24 @@ public class ProcessParameterPanel extends Panel implements if (sb.length() > 0) sb.append(", "); sb.append(field.getHeader()); + if (m_wEditors2.get(i) != null) // is a range + sb.append(" (").append(Msg.getMsg(Env.getCtx(), "From")).append(")"); } else field.setError(false); // Check for Range WEditor wEditor2 = (WEditor) m_wEditors2.get(i); if (wEditor2 != null) { - Object data2 = wEditor.getValue(); + Object data2 = wEditor2.getValue(); GridField field2 = (GridField) m_mFields2.get(i); if (data2 == null || data2.toString().length() == 0) { - field.setInserting(true); // set editable (i.e. + field2.setInserting(true); // set editable (i.e. // updateable) otherwise // deadlock field2.setError(true); if (sb.length() > 0) sb.append(", "); - sb.append(field.getHeader()); + sb.append(field2.getHeader()); + sb.append(" (").append(Msg.getMsg(Env.getCtx(), "To")).append(")"); } else field2.setError(false); } // range field diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java index 4b391c2245..dfcf9c0ff8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java @@ -115,7 +115,9 @@ public class WNumberEditor extends WEditor implements ContextMenuListener getComponent().getDecimalbox().setCols(displayLength); } - if (!DisplayType.isNumeric(displayType)) + if (DisplayType.isID(displayType)) + displayType = DisplayType.Integer; + else if (!DisplayType.isNumeric(displayType)) displayType = DisplayType.Number; DecimalFormat format = DisplayType.getNumberFormat(displayType, AEnv.getLanguage(Env.getCtx())); getComponent().getDecimalbox().setFormat(format.toPattern()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index f8b33d51e9..70f85d98ce 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -16,6 +16,8 @@ *****************************************************************************/ package org.adempiere.webui.window; +import static org.compiere.model.SystemIDs.WINDOW_PRINTFORMAT; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.StringWriter; @@ -57,10 +59,10 @@ import org.compiere.model.MRole; import org.compiere.model.MSysConfig; import org.compiere.model.MTable; import org.compiere.model.MUser; -import static org.compiere.model.SystemIDs.*; import org.compiere.print.ArchiveEngine; import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; +import org.compiere.tools.FileUtil; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -723,7 +725,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab try { - attachment = File.createTempFile("mail", ".pdf"); + attachment = new File(FileUtil.getTempMailName(subject, ".pdf")); m_reportEngine.getPDF(attachment); } catch (Exception e) diff --git a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java index 774fce026d..928e6d8b4f 100644 --- a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java +++ b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java @@ -313,6 +313,9 @@ public class ReportCtl if(format.getJasperProcess_ID() > 0) { ServerReportCtl.runJasperProcess(Record_ID, re, IsDirectPrint, printerName); + if (IsDirectPrint) { + ReportEngine.printConfirm(type, Record_ID); + } } else // Standard Print Format (Non-Jasper) diff --git a/org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config/ConfigOracle.java b/org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config/ConfigOracle.java index 2e4bdf9f08..418290d2a1 100644 --- a/org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config/ConfigOracle.java +++ b/org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config/ConfigOracle.java @@ -382,12 +382,17 @@ public class ConfigOracle implements IDatabaseConfig data.setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser); data.setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword); + String ospath; + if (System.getProperty("os.name").startsWith("Windows")) + ospath = "windows"; + else + ospath = "unix"; // TNS Name Info via sqlplus String sqlplus = "sqlplus system/" + systemPassword + "@" + "//" + databaseServer.getHostName() + ":" + databasePort + "/" + databaseName - + " @utils/oracle/Test.sql"; + + " @utils." + ospath + "/oracle/Test.sql"; log.config(sqlplus); pass = testSQL(sqlplus); error = "Error connecting via: " + sqlplus;