MInOutLine beforeDelete() for Invalid MInOut

Andrea
2009-02-20
2013-05-02
  • Andrea
    Andrea
    2009-02-20

    Dear Adempiere developers,

    while using Adempiere I'm always facing this problem: I have a lot of Material Receipt (MInOut) that goes to DocStatus=DOCACTION_Invalidate (e.g. due the fact that a product has mandatory attribute set instance but this has not been entered yet)
    When it goes to this DocState I cannot erase MInOutLine anymore, see MInOutLine.beforeDelete().
    Unfortunately sometimes it happens that the "best" thing to do to make MInOut to return to a valid state and allow me to complete it, is to delete some MInOutLine (e.g. the above line without ASI)

    I have an old version of Adempiere (3.2.0, merged with some more recent changed for bug fixed) but the same is in the current trunk.

    I make the following patch to allow MInOutLine deletion even if DocState is Invalidate

    diff --git a/base/src/org/compiere/model/MInOutLine.java b/base/src/org/compiere/model/MInOutLine.java
    index ccb2a06..cf5b16c 100644
    --- a/base/src/org/compiere/model/MInOutLine.java
    +++ b/base/src/org/compiere/model/MInOutLine.java
    @@ -607,7 +607,8 @@ public class MInOutLine extends X_M_InOutLine
          */
         protected boolean beforeDelete ()
         {
    -        if (getParent().getDocStatus().equals(MInOut.DOCSTATUS_Drafted))
    +        if (getParent().getDocStatus().equals(MInOut.DOCSTATUS_Drafted)
    +                || getParent().getDocStatus().equals(MInOut.DOCACTION_Invalidate))
                 return true;
             log.saveError("Error", Msg.getMsg(getCtx(), "CannotDelete"));
             return false;

    Do you think this can lead to some problems or is safe?

    Best Regards,

    Andrea

     
    • Hamza khanfouf
      Hamza khanfouf
      2009-03-14

      In standard Compiere we delete if drafted or in progress.