IDEMPIERE-1732 two users can complete same M_InOut and data is corrupted / peer review and integrate patch from hengsin

This commit is contained in:
Carlos Ruiz 2014-02-07 15:47:22 -05:00
parent 3c8bc873dc
commit 93b7e0b75b
4 changed files with 32 additions and 4 deletions

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Feb 7, 2014 3:29:48 PM COT
-- IDEMPIERE-1732 two users can complete same M_InOut and data is corrupted
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Document status has been changed by other session, please refresh the record and try again.',200254,'D','de43afaf-61eb-4b85-bedd-5c599133a3f9','DocStatusChanged','Y',TO_DATE('2014-02-07 15:29:46','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2014-02-07 15:29:46','YYYY-MM-DD HH24:MI:SS'),0)
;
SELECT register_migration_script('201402071531_IDEMPIERE-1732.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- Feb 7, 2014 3:29:48 PM COT
-- IDEMPIERE-1732 two users can complete same M_InOut and data is corrupted
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('E','Document status has been changed by other session, please refresh the record and try again.',200254,'D','de43afaf-61eb-4b85-bedd-5c599133a3f9','DocStatusChanged','Y',TO_TIMESTAMP('2014-02-07 15:29:46','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2014-02-07 15:29:46','YYYY-MM-DD HH24:MI:SS'),0)
;
SELECT register_migration_script('201402071531_IDEMPIERE-1732.sql') FROM dual
;

View File

@ -48,6 +48,7 @@ import org.compiere.model.PO;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.eevolution.model.I_DD_Order;
import org.eevolution.model.I_HR_Process;
@ -235,11 +236,13 @@ public class DocumentEngine implements DocAction
if (docPO.get_ID() > 0 && docPO.get_TrxName() != null && docPO.get_ValueOld("DocStatus") != null) {
DB.getDatabase().forUpdate(docPO, 30);
String docStatusOriginal = (String) docPO.get_ValueOld("DocStatus");
String currentStatus = DB.getSQLValueString((String)null,
"SELECT DocStatus FROM " + docPO.get_TableName() + " WHERE " + docPO.get_KeyColumns()[0] + " = ? ",
docPO.get_ID());
String statusSql = "SELECT DocStatus FROM " + docPO.get_TableName() + " WHERE " + docPO.get_KeyColumns()[0] + " = ? ";
String currentStatus = DB.getSQLValueString((String)null, statusSql, docPO.get_ID());
if (!docStatusOriginal.equals(currentStatus) && currentStatus != null) {
throw new IllegalStateException("Document status have been change by other session, please refresh your window and try again. " + docPO.toString());
currentStatus = DB.getSQLValueString(docPO.get_TrxName(), statusSql, docPO.get_ID());
if (!docStatusOriginal.equals(currentStatus)) {
throw new IllegalStateException(Msg.getMsg(docPO.getCtx(), "DocStatusChanged") + " " + docPO.toString());
}
}
}
}

View File

@ -357,6 +357,12 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
}
private void setValueAndClose() {
String statusSql = "SELECT DocStatus FROM " + gridTab.getTableName()
+ " WHERE " + gridTab.getKeyColumnName() + " = ? ";
String currentStatus = DB.getSQLValueString((String)null, statusSql, gridTab.getKeyID(gridTab.getCurrentRow()));
if (DocStatus != null && !DocStatus.equals(currentStatus)) {
throw new IllegalStateException(Msg.getMsg(Env.getCtx(), "DocStatusChanged"));
}
m_OKpressed = true;
setValue();
detach();