magento / inventory

Magento Inventory Project (a.k.a MSI)
Open Software License 3.0
337 stars 248 forks source link

Salable Qty wrong after increasing stock #2389

Open FranRoy opened 5 years ago

FranRoy commented 5 years ago

Preconditions

  1. Magento 2.3.1 CE
  2. nginx 1.12 PHP 7.2
  3. Multistore (2 stores)
  4. This is a migration from 2.1.7 to 2.3.1. I used to manage my inventory with BoostMyShop but before the migration, I disabled the module and set all product stocks to 0, so that, after migration to 2.3.1, all my products had 0 stock.

Steps to reproduce

  1. Create 1 source Barcelona and 1 stock Barcelona

step0 step1

  1. Assign created source to product stock and set source stock to 5

steop

Expected result

  1. Quantity per Source should be equal to Salable Qty
  2. Barcelona Quantity should be 5, Barcelona Salable Quantity should be 5

Actual result

  1. Salable quantity is 15 which is wrong. In fact, for any number I set as stock, Salable quantity is always x3 the Source Stock (i.e, Source Stock set to 50 -> Salable Qty is 150).

* If I create a new product from scratch, the Salable Quantity is well calculated after setting the source Quantity. It only occurrs with old products.

step2

ishakhsuvarov commented 5 years ago

Hi @FranRoy Have you done any order manipulations with the old items in question? Or is it just in this state straight after upgrade? Do you have any non-default inventory settings? For example backorders or smth like that?

FranRoy commented 5 years ago

Hello @ishakhsuvarov, thanks for your answer.

No, everything is by default and I don't use backorders. The only thing not by default is that previously to the upgrade, I used an Inventory Management module (boostMyShop ERP). I disabled it before the upgrade and set all stocks to 0.

The table inventory_stock_2 which I assume stores salable data for that specific source, stores the wrong value after I update de stock (in this case, sets to 15 when It should be 5).

inventory_stock2

Do you know which parts involving the salabe quantity formula/process could be wrongly altering the data?

Thanks a lot!

Fran

ishakhsuvarov commented 5 years ago

@FranRoy Don't have a clue of anything doing exactly 3x multiplication. Do you have any more extensions somehow related to the inventory? Also, you might want to check if there is anything strange happening in the exception log.

FranRoy commented 5 years ago

Hi @ishakhsuvarov nothing strange in exception.log :( I don't have any other extensions related to inventory or that affect products at all. Can the fact that new products work fine, give any kind of clue about the origin of the issue?

Thanks!

ishakhsuvarov commented 5 years ago

@FranRoy Still thinking on it. Obviously it looked like multiple attempts to save. Also, processing of the existing orders can theoretically produce artifacts on existing products after upgrade. Nothing specific comes to mind at this point. Can you check your inventory_reservation table for anything related to those skus just in case? even though it's unlikely to be the case now.

FranRoy commented 5 years ago

Hello @ishakhsuvarov , inventory_reservation is empty, I have no open orders (I supose that's why).

Thanks,

Fran.

ishakhsuvarov commented 5 years ago

@FranRoy I've got some information that similar issue was already discussed before. Working on getting some information on the resolution and will let you know.

FranRoy commented 5 years ago

Hello @ishakhsuvarov

Did you get the information or have any news?

Thanks!

ishakhsuvarov commented 5 years ago

Hi @FranRoy

Unfortunately I couldn't find any exact information.

Please reach out to me on Magento Community Slack and we can try to diagnose it.

Thanks

juhanihaapala commented 5 years ago

Hi, I noticed similar issue when updateing stock qty with api. It seems that the qty is not updated to cataloginventory_stock_status table which is used to calculate the salable qty through the inventory_stock_1 view.

gwharton commented 5 years ago

See #2454 for some more shenanigans similar to this issue.