IDEMPIERE-103 - In progress invocies can not be deleted if linked with an Order

This commit is contained in:
Hesham S. Ahmed 2012-07-10 21:00:53 +03:00
parent ee8cc74127
commit 28ac2b4f83
1 changed files with 24 additions and 2 deletions

View File

@ -984,12 +984,34 @@ public class MInvoice extends X_C_Invoice implements DocAction
{ {
if (getC_Order_ID() != 0) if (getC_Order_ID() != 0)
{ {
log.saveError("Error", Msg.getMsg(getCtx(), "CannotDelete")); //Load invoice lines for afterDelete()
return false; getLines();
} }
return true; return true;
} // beforeDelete } // beforeDelete
/**
* After Delete
* @param success success
* @return deleted
*/
protected boolean afterDelete(boolean success) {
// If delete invoice failed then do nothing
if (!success)
return success;
if (getC_Order_ID() != 0) {
// reset shipment line invoiced flag
MInvoiceLine[] lines = getLines(false);
for (int i = 0; i < lines.length; i++) {
MInOutLine sLine = new MInOutLine(getCtx(), lines[i].getM_InOutLine_ID(), get_TrxName());
sLine.setIsInvoiced(false);
sLine.saveEx();
}
}
return true;
} //afterDelete
/** /**
* String Representation * String Representation
* @return info * @return info