logic to check negative on-hand for warehouse don't work 100% if IsDisallowNegativeInv change sometime


1. when we change "Disallow Negative Inventory" of warehouse from false to true idempiere check quality per warehouse
logic at MWarehouse.beforeSave

2. when do a movement, idempiere check "Disallow Negative Inventory" per locator
logic at MStorageOnHand.addQtyOnHand


suppose we have two StorageOnHand record and warehouse is allow negative
onhand_1 record quality = -100
onhand_2 record quality = 200
now we change warehouse to disallow negative. it's ok because total on warehouse > 0

issue 1:
do a warehouse movement in quality = 50, by logic it choose record onhand_1 to auto balancing
logic on MStorageOnHand.addQtyOnHand will raise NegativeInventoryDisallowed exception

issue 2:
do a warehouse movement out quality = 150, by logic it choose record onhand_2 to process, so after that we have
onhand_1 record quality = -100
onhand_2 record quality = 50
so now total quality on warehouse is negative, conflict with properties "Disallow Negative Inventory"

, , wdyt?

i description it base on status of my data. but it can be get test case to redo. i will provide test case late.




Norbert Bede
June 28, 2017, 1:21 PM

i can confirm time-to-time system hit negative levels when disallow quantity is 0.
Mainly when inventory moves created on warehouse locators across organisations.

Norbert Bede
June 28, 2017, 1:29 PM

can be related - DisallowNegativeQty checks also Locator To

Hiep Lq
June 30, 2017, 1:05 PM

issue 1: for me it's ok to by pass check Negative Inventory in case move on warehouse

Carlos Ruiz
July 4, 2017, 11:40 AM

, I think your test case is not reproducible - if there is a reproducible test case where disallow negative inventory is set and a storage is saved negative then is a bug (we recently fixed one in production doc).

About the sync between the logic in validation and the logic in storage - if the data can be fixed after set (maybe with a Storage Cleanup, or a movement, or a physical inventory) that would be OK, if the data cannot be fixed then we have a problem.

Hiep Lq
January 19, 2018, 5:28 PM

i do same patch at to fix this issue




Hiep Lq


Tested By



Affects versions