order line QtyInsufficient error

  • Zuhair Hammadi

    Zuhair Hammadi - 2012-09-30

    Hi all,

    I'm getting error in the sales order line when a product have non instance attribute.

    system check the inventory and give insufficient quantity error.

    line have non instance attribute and instance attribute not set.

    system should not raise error if instance attribute not set.

    Zuhair Hammadi

  • Frankie Figs

    Frankie Figs - 2012-10-01

    Hey Zuhair,

    You can exclude the mandatory behavior of instance attributes over the tables you define merit such a behavior. Check of the ticket https://adempiere.atlassian.net/browse/ADEMPIERE-79 for more information.


  • Zuhair Hammadi

    Zuhair Hammadi - 2012-10-02

    Hi Frankie ,

    The error I get is not on completing the order, its on saving order line.

    Orderline model not check for mandatory behavior of instance attributes.
    it check inventory and raise error.

    M_AttributeSetInstance_ID is set when you select the product because it has non instance attribute.


    // Qty on instance ASI for SO
    if (m_IsSOTrx
    && getM_AttributeSetInstance_ID() != 0
    && (newRecord || is_ValueChanged("M_Product_ID")
    || is_ValueChanged("M_AttributeSetInstance_ID")
    || is_ValueChanged("M_Warehouse_ID")))
    MProduct product = getProduct();
    if (product.isStocked())
    int M_AttributeSet_ID = product.getM_AttributeSet_ID();
    boolean isInstance = M_AttributeSet_ID != 0;
    if (isInstance)
    MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID);
    isInstance = mas.isInstanceAttribute();
    // Max
    if (isInstance)
    MStorage storages = MStorage.getWarehouse(getCtx(),
    getM_Warehouse_ID(), getM_Product_ID(), getM_AttributeSetInstance_ID(),
    M_AttributeSet_ID, false, null, true, get_TrxName());
    BigDecimal qty = Env.ZERO;
    for (int i = 0; i < storages.length; i++)
    if (storages_.getM_AttributeSetInstance_ID() == getM_AttributeSetInstance_ID())
    qty = qty.add(storages.getQtyOnHand());

    if (getQtyOrdered().compareTo(qty) > 0)
    log.warning("Qty - Stock=" + qty + ", Ordered=" + getQtyOrdered());
    <b>log.saveError("QtyInsufficient", "=" + qty); </b>
    return false;
    } // stocked
    } // SO instance

    Zuhair Hammadi_

  • Frankie Figs

    Frankie Figs - 2012-10-02

    Ah yes, I think it is an annoying message as well.

    Thank you very much for sharing those lines of code and forgive me for mis-understanding !


  • Zuhair Hammadi

    Zuhair Hammadi - 2012-10-03

    thanks for your cooperation

  • Colin Rooney

    Colin Rooney - 2012-10-03

    Have a read of this old forum thread, I suspect it might relate to your problem.

    Do note the very last post that contradicts me… I never did get to check if that suggestion was right or wrong but my understanding remains as I posted there. 


  • Frankie Figs

    Frankie Figs - 2012-10-04

    That is one tough thread but very interesting never the less. I think that this website is very related to what was said: http://www.gs1.org/gdsn/gpc/what. It is a methodology for classifying all possible products and at the level of maximum detail are those… (Static,Non-Instance,Descriptive) Attributes.

    I would like to recreate the scenario that you are describing. By the way, in the thread posted by croo, user beta2799 describes the following scenario and arrives at the same error message in question:

    I have encountered the same problem as well while I did the test on Adempiere 3.2.0. I think it's a ASI bug. It's should be fixed in the trunk. Please comment and try to reproduce as following steps:

    1. Create an attribute set with instance attribute of Color and Size
    2. Create a product with the attribute set created in Step 1
    3. Create a Standard Order
    4. Add a order line with the product created in Step 2 without ASI and Save (it'd be successful with qty warning message)
    5. Add a order line with the product created in Step 2 with ASI (Color and Size) and Save (it'd be failure with qty error message "Insufficient Qty on hand")


  • Zuhair Hammadi

    Zuhair Hammadi - 2012-10-04

    when a product have attribute set
    non instance attribute like color, size which was set for product
    instance attribute like serial no

    when creating a sales order line and choose this product,
    ASI is automatically set with non instance attribute same as product have.

    you cannot remove this ASI, and error raised when you save.

    so I just add this line of code in beforeSave trigger

    isInstance = (getM_AttributeSetInstance_ID() != product.getM_AttributeSetInstance_ID());

    Zuhair Hammadi


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks