Inventory: Fix an inventory cache issue

The issue is occured when using inventory document with inventory cache.
Add a test case to make sure this issue has been solved:
  testInventory#test_18_InventoryDocumentAndInventoryCache.