diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLine.java b/org.adempiere.base/src/org/compiere/model/MInOutLine.java index e4dc303c82..2245831c49 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLine.java @@ -642,10 +642,20 @@ public class MInOutLine extends X_M_InOutLine */ protected boolean beforeDelete () { - if (getParent().getDocStatus().equals(MInOut.DOCSTATUS_Drafted)) - return true; - log.saveError("Error", Msg.getMsg(getCtx(), "CannotDelete")); - return false; + if (! getParent().getDocStatus().equals(MInOut.DOCSTATUS_Drafted)) { + log.saveError("Error", Msg.getMsg(getCtx(), "CannotDelete")); + return false; + } + // IDEMPIERE-3391 Not possible to delete a line in the Material Receipt window + List ils = new Query(getCtx(), MInvoiceLine.Table_Name, "M_InOutLine_ID=?", get_TrxName()) + .setParameters(getM_InOutLine_ID()) + .list(); + ils.forEach(il -> { + il.setM_InOutLine_ID(-1); + il.saveEx(); + }); + // + return true; } // beforeDelete /**