spree/spree — pull request #3586 by huoxito (2013-08-18 06:56:42+00:00)
Title: Make AvailabilityValidator aware of inventory units

When checking stock from line items related to shipments and inventory
units we need to check stock according to the inventory units count and
not only to the line item quantity. e.g. typical case

Store has 5 of item A in stock
Customer purchases 5 of item A
Store creates 5 inventory units once order is completed
At this point item A is out of stock

Store admin wants to ship only 4 of Item A
Spree should be able to decrease that quantity and restock the item

The store don't need to check stock for Item A in that scenario because
it's actually decreasing the item quantity. In fact we need to restock 1
item back to the stock location

Possible fix for #3575 (2-0-stable also needs it). I think this still doesn't cover all cases. Users might still get unexpected results when a variant is spread into multiple shipments (via inventory units). It seems to me the best way to fix it 100% is to associate inventory units directly with line items. I'll investigate it further and try that approach later on.