diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLine.java b/org.adempiere.base/src/org/compiere/model/MInOutLine.java index 50969cebd0..3e45cea184 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLine.java @@ -517,8 +517,26 @@ public class MInOutLine extends X_M_InOutLine if (getParent().pendingConfirmations()) { if ( newRecord || (is_ValueChanged(COLUMNNAME_MovementQty) && !is_ValueChanged(COLUMNNAME_TargetQty))) { - log.saveError("SaveError", Msg.parseTranslation(getCtx(), "@Open@: @M_InOutConfirm_ID@")); - return false; + + if (getMovementQty().signum() == 0) + { + String docAction = getParent().getDocAction(); + String docStatus = getParent().getDocStatus(); + if ( MInOut.DOCACTION_Void.equals(docAction) + && ( MInOut.DOCSTATUS_Drafted.equals(docStatus) + || MInOut.DOCSTATUS_Invalid.equals(docStatus) + || MInOut.DOCSTATUS_InProgress.equals(docStatus) + || MInOut.DOCSTATUS_Approved.equals(docStatus) + || MInOut.DOCSTATUS_NotApproved.equals(docStatus) + ) + ) + { + // OK to save qty=0 when voiding + } else { + log.saveError("SaveError", Msg.parseTranslation(getCtx(), "@Open@: @M_InOutConfirm_ID@")); + return false; + } + } } } // Locator is mandatory if no charge is defined - teo_sarca BF [ 2757978 ] diff --git a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java index b2c7222150..4bb131c938 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java @@ -604,12 +604,39 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); if (m_processMsg != null) return false; + + + MMovement move = new MMovement (getCtx(), getM_Movement_ID(), get_TrxName()); + for (MMovementLineConfirm confirmLine : getLines(true)) + { + confirmLine.setTargetQty(Env.ZERO); + confirmLine.setConfirmedQty(Env.ZERO); + confirmLine.setScrappedQty(Env.ZERO); + confirmLine.setDifferenceQty(Env.ZERO); + confirmLine.setProcessed(true); + confirmLine.saveEx(); + } + + // set confirmation as processed to allow voiding the inventory move + setProcessed(true); + saveEx(); + + // voiding the confirmation voids also the inventory move + ProcessInfo processInfo = MWorkflow.runDocumentActionWorkflow(move, DocAction.ACTION_Void); + if (processInfo.isError()) + { + m_processMsg = processInfo.getSummary(); + setProcessed(false); + return false; + } + // After Void m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); if (m_processMsg != null) return false; - - return false; + + setDocAction(DOCACTION_None); + return true; } // voidIt /**