Magento2: Multisource Inventory, can't ship items when using default Stocks

Created on 8 Mar 2019  路  20Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento 2.3
  2. Multisource inventory setup to use default stock

Steps to reproduce (*)

  1. Create a simple product with Qty 1
  2. Complete checkout process with that product
  3. Go to admin panel: try to create shipment for that order

Expected result (*)

  1. Shipment should be created, no errors

Actual result (*)

  1. Error: Not all of your products are available in the requested quantity.

I've debugged this to be an issue with
vendor/magento/module-inventory-source-deduction-api/Model/SourceDeductionService.php class and it's execute method
When multiple source inventory module uses defalts stock, it should not check stock of any sources.
I personally think that entire Source Selection / Deduction should be removed from module logic when default stock is being used.

Format is valid needs update

All 20 comments

Hi @qsolutions-pl. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@qsolutions-pl do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

The corresponding ticket created on MSI GitHub https://github.com/magento-engcom/msi/issues/2073

But current steps to reproduce are not enough to replicate the issue, as the most basic scenario is described which is covered by both Functional Acceptance and integration tests and non-reproducible on clean Magento 2.3 installation with MSI.

I have several questions which could shed some light and lead us to finding a root cause of the issue:

  1. Do you have any 3PD extensions installed which affect the default inventory flow or modify inventory calculation
  2. How many stocks you have created? Just default one or there are other Sources/Stocks create? If you have more than one stock/sources - please describe how these sources assigned to stocks
  3. What Quantity did you set to Product while creating it? Did you use admin UI or created product and set Qty programmatically?
  4. What Quantity did you use during the Order placement?
  5. What product Qty you have in source item table?
    mysql> select * from inventory_source_item where sku = %you sku%;
  6. What product Qty you have in legacy Catalog Inventory StockItem table?
    mysql> select * from cataloginventory_stock_item where product_id = %your product id% \G
  7. What reservations you have created for this product?
    mysql> select * from inventory_reservation where sku = %you sku%;
  1. There are no 3rd party extensions related to stock management
  2. We created only 1 stock, default one
  3. Product Qty = 1, product was created in admin UI, managed stock
  4. Ordered 1 qty
  5. 15
  6. 15
  7. 0

Stock was updated by the client over the weekend.
Could this be related to Magento 2.2 -> 2.3 upgrade which was done last week?

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • _Next steps are available in case you are a member of Community Maintainers._

  • [ ] 6. Add label Issue: Confirmed once verification is complete.

  • [ ] 7. Make sure that automatic system confirms that report has been added to the backlog.

hey @qsolutions-pl ,

We created only 1 stock, default one

did you create Default stock or it was created by Magento in the scope of installation/upgrade?

5. 15
6. 15
7. 0

This looks strange because as you see Magento considers that you have 15 items of this product, but not 0.

Could this be related to Magento 2.2 -> 2.3 upgrade which was done last week?

If you proceed with Magento 2.2 -> 2.3 upgrade we disable all new Inventory modules (read the whole MSI) to prevent any possible Backward Incompatibilities (for example, if a merchant had some inventory customizations), and the absence of reservations (step 7. 0) proofs that MSI was not active when your order has been placed, because since Magento 2.3.0 all the orders lead to inventory reservation being created.

Hi @qsolutions-pl thank you for you report, i'm not able to reproduce following steps you described, this may be related to your environment or some custom data. please try reproduce this on clean 2.3 magento .

Reopened because we are still waiting @qsolutions-pl to provide more details regarding this issue.

@engcom-backlog-nazar did you trying to reproduce via the initial steps or applying 2.2 -> 2.3 upgrade procedure?

@maghamed no, only with clean 2.3.0 instance, but in which version of 2.2 we need upgrade ? 2.2.6 or 2.2.7 ?

We upgraded from 2.2.6 -> 2.3.0
And to answer one of the questions above, there were never any customizations done to inventory processing, there was no need to.
I will try to replicate the scenario this week once I have some free time (probably friday).

@qsolutions-pl
The point is that during migration 2.2.* -> 2.3.0
We disable all MSI modules and business logic to prevent it from affecting possible existing customizations.

Thanks why in fact, you don't have MSI running on your instance of Magento

Hi @qsolutions-pl any updates ?

@qsolutions-pl i'm closing this for now, as i'm not able to reproduce with upgrading from 2.2.6 or 2.2.7 to 2.3.0 have no issue. if you find a way to reproduce this issue please feel free to reopen this one.

I have the same problem, we have linked Magento to another system managing our stock and shipments. When an order is placed the stock is changed by this system from 1 to 0 and when stock is 0 it's not possible to create a shipment in Magento 2.3. Is there a workaround for this issue?

I'm having same problem as istoutjesdijk is there a work around?

@merance2000 I solved the problem by disabling MSI completely. This is the best solution when you have and external system managing your stock. (https://www.mexbs.com/magento-blog/disabling-the-magento-msi/)

I also disabled "Decrease Stock When Order is Placed" in the configuration under "Inventory".

I have this same issue and I am using core vanilla 2.3 code. I have a product configured with quantity 19 and an order placed for 59 units. When creating shipment in the admin UI, I receive the error "Not all of your products are available in the requested quantity.". This error is coming from module-inventory-source-deduction-api/Model/SourceDeductionService.php.

        $sourceItem = $this->getSourceItemBySourceCodeAndSku->execute($sourceCode, $itemSku);
        if (($sourceItem->getQuantity() - $qty) >= 0) {
            $sourceItem->setQuantity($sourceItem->getQuantity() - $qty);
            $sourceItems[] = $sourceItem;
        } else {
            throw new LocalizedException(
                __('Not all of your products are available in the requested quantity.')
            );
        }

The admin panel allows you to configure sell below 0, however the code above has no check or concern about this setting which is significantly different behavior than 1x. IMO the designed behavior is not explained and conflicts with how the product can be configured in the admin panel. Can someone from the core team please explain if this is expected behavior why it is allowed to configure to sell below 0 but yet prevent creation of shipment.

2020-01-05_20-03-54

2020-01-05_20-04-34

IMO, the product configuration should CLEARLY explain that configuring selling below 0 will prevent shipment from being created, especially because prior to M2 this was standard behavior

I have this same issue and I am using core vanilla 2.3 code. I have a product configured with quantity 19 and an order placed for 59 units. When creating shipment in the admin UI, I receive the error "Not all of your products are available in the requested quantity.". This error is coming from module-inventory-source-deduction-api/Model/SourceDeductionService.php.

        $sourceItem = $this->getSourceItemBySourceCodeAndSku->execute($sourceCode, $itemSku);
        if (($sourceItem->getQuantity() - $qty) >= 0) {
            $sourceItem->setQuantity($sourceItem->getQuantity() - $qty);
            $sourceItems[] = $sourceItem;
        } else {
            throw new LocalizedException(
                __('Not all of your products are available in the requested quantity.')
            );
        }

The admin panel allows you to configure sell below 0, however the code above has no check or concern about this setting which is significantly different behavior than 1x. IMO the designed behavior is not explained and conflicts with how the product can be configured in the admin panel. Can someone from the core team please explain if this is expected behavior why it is allowed to configure to sell below 0 but yet prevent creation of shipment.

We have this issue time and time again. How is this issue closed? Obviously there are so many merchants that suffer from this issue and I could find no explanation or sufficient solution except disabling MSI completely. Sometimes we can't just turn off MSI because some other modules like Magesuite rely on it.

https://magento.stackexchange.com/questions/277993/disable-stock-check-decrease-when-shipping-an-order-in-magento-2-3-1
https://magento.stackexchange.com/questions/269982/magento-2-cant-ship-order-in-the-backend
https://github.com/magento/inventory/issues/2725

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzalenski picture jzalenski  路  3Comments

salelsol picture salelsol  路  3Comments

punkstar picture punkstar  路  3Comments

denis-g picture denis-g  路  3Comments

fvillata picture fvillata  路  3Comments