diff --git a/migration/i2.0/oracle/201402071531_IDEMPIERE-1732.sql b/migration/i2.0/oracle/201402071531_IDEMPIERE-1732.sql new file mode 100644 index 0000000000..6177dbc36f --- /dev/null +++ b/migration/i2.0/oracle/201402071531_IDEMPIERE-1732.sql @@ -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 +; + diff --git a/migration/i2.0/postgresql/201402071531_IDEMPIERE-1732.sql b/migration/i2.0/postgresql/201402071531_IDEMPIERE-1732.sql new file mode 100644 index 0000000000..8c2df200fd --- /dev/null +++ b/migration/i2.0/postgresql/201402071531_IDEMPIERE-1732.sql @@ -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 +; + diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java index da6f38add4..632b18bccf 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java @@ -403,6 +403,16 @@ public class Doc_MatchInv extends Doc as.getC_Currency_ID(), ipv.negate()); updateFactLine(line); + line = fact.createLine(null, account, as.getC_Currency_ID(), ipv); + updateFactLine(line); + } else if (X_M_Cost.COSTINGMETHOD_AverageInvoice.equals(costingMethod) && !zeroQty) { + MAccount account = m_pc.getAccount(ProductCost.ACCTTYPE_P_Asset, as); + + FactLine line = fact.createLine(null, + m_pc.getAccount(ProductCost.ACCTTYPE_P_IPV, as), + as.getC_Currency_ID(), ipv.negate()); + updateFactLine(line); + line = fact.createLine(null, account, as.getC_Currency_ID(), ipv); updateFactLine(line); } diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 5ac7f638ed..069c02478d 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -1828,6 +1828,18 @@ public class MInvoice extends X_C_Invoice implements DocAction matchPO++; if (!po.isPosted() && po.getM_InOutLine_ID() > 0) // match po don't post if receipt is not assigned, and it doesn't create avg po record addDocsPostProcess(po); + + MMatchInv[] matchInvoices = MMatchInv.getInvoiceLine(getCtx(), line.getC_InvoiceLine_ID(), get_TrxName()); + if (matchInvoices != null && matchInvoices.length > 0) + { + for(MMatchInv matchInvoice : matchInvoices) + { + if (!matchInvoice.isPosted()) + { + addDocsPostProcess(matchInvoice); + } + } + } } } } diff --git a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java index 4bbdba8371..d707a4a9f0 100644 --- a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java +++ b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java @@ -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()); + } } } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java index f89cfb4b5e..db88c93ae0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java @@ -357,6 +357,12 @@ public class WDocActionPanel extends Window implements EventListener, 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();