magento / magento/inventory

Weird flip of saleable qty = 1 and qty = 0 when placing shipment of order

Open
#2,827 4 comments 1 reaction 0 assignees View on GitHub
Bug
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

Hi guys, we experienced a weird issue concerning shipments that can’t be placed because an item is not in stock. The following error came up: 'Not all of your products are available in the requested quantity.'

First of all, how is it even possible that this scenario can happen. I was able to reproduce it on 2.3.2 and 2.3.3. It seems partially fixed in 2.3.4

### Preconditions (*)

1. Magento 2.3.2, 2.3.3 or 2.3.4 Open source
2. inventory-composer-metapackage enabled
3. The indexers should be set on schedule

### Steps to reproduce (*)

1. Make an order of a product that has qty = 1, saleable qty = 1
2. The product is still in pending but the qty = 1, saleable qty = 0
At this moment you cannot order the same product
3. Invoice and ship the order. Now something strange happens. The qty = 0 but the saleable qty = 1
4. Reindex: bin/magento indexer:reindex inventory cataloginventory_stock
5. Now the qty = 0 and saleable qty = 0. Product can’t be ordered again.

In step 3 we have this weird flip: qty = 0 and saleable qty = 1. I was able to re-order this product, and even invoice it on version 2.3.2 and 2.3.3. In the newest 2.3.4 version, the out-of-stock status is changed to 0, which wasn't the case in 2.3.2 and 2.3.3. This prevents the product from being sold on the frontend.

From the moment I try to ship the new order, I get the error: ‘Not all of your products are available in the requested quantity.’

So if the automatic reindexing takes a while or is stuck for some reason, there’s a possibility that people can reorder products that are out of stock.

I think that this flip in step 3 should not occur.

### Expected result (*)

2. Saleable qty should stay 0 after shipment

### Actual result (*)

2. Saleable qty becomes 1 after shipment

Contributor guide

Open the contributing guide

Research direction

Reproduce the shipment flow across Magento 2.3.2–2.3.4 using the listed inventory preconditions and steps. Run `bin/magento indexer:reindex inventory cataloginventory_stock` after shipment and compare quantity, saleable quantity, and stock status before and after reindexing. Done means saleable quantity remains 0 after shipment and the out-of-stock product cannot be reordered or shipped.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.