Menu

#2672 Document number is updated again after reactivation

Core
open-fixed
nobody
None
5
2011-08-28
2011-08-24
No

This refers to usage of the feature "Enhance document numbering" as described in
https://sourceforge.net/tracker/index.php?func=detail&aid=1860642&group_id=176962&atid=879335

When for a document type (e.g. Standard Order) the selection "Overwrite Sequence on Complete" has been checked (and a "Definite Sequence" has been defined) the document number is taken from this sequence when the document is completed.

When you reactivate the document to change a quantity for example and you complete it again you get a new document number again.

The cause lies in MOrder.setDefiniteDocumentNo() which does not check if it did its work already.

Regards,
Dirk Niemeyer

Discussion

  • Dirk Niemeyer

    Dirk Niemeyer - 2011-08-24

    Proposed fix for MOrder:

    --- base/src/org/compiere/model/MOrder.java
    +++ base/src/org/compiere/model/MOrder.java
    * Set the definite document number after completed
    */
    private void setDefiniteDocumentNo() {
    MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
    if (dt.isOverwriteDateOnComplete()) {
    - setDateOrdered(new Timestamp (System.currentTimeMillis()));
    + /* check if document has been completed before */
    + if (this.getProcessedOn().compareTo(Env.ZERO) == 0) {
    + setDateOrdered(new Timestamp (System.currentTimeMillis()));
    + }
    }
    if (dt.isOverwriteSeqOnComplete()) {
    - String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this);
    - if (value != null)
    - setDocumentNo(value);
    + /* check if document has been completed before */
    + if (this.getProcessedOn().compareTo(Env.ZERO) == 0) {
    + String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this);
    + if (value != null)
    + setDocumentNo(value);
    + }
    }
    }

     
  • Dirk Niemeyer

    Dirk Niemeyer - 2011-08-28
    • status: open --> open-fixed
     

Log in to post a comment.