Saleor: Populatedb script creates out-of-stock variants

Created on 16 Aug 2018  路  5Comments  路  Source: mirumee/saleor

In this line we generate random quantity_allocated which may result in an impractical state of having out-of-stock variants without corresponding orders. This should be dropped in my opinion.
On the other hand in create_order_line function we create fake orders and allocate appropriate quantity which is totally fine as it corresponds with a real-life case.

bug in progress

All 5 comments

I see in the quantity_allocated function it generates a random quantity between 1 and 50, and then another random between 1 and 50 for the quantity_allocated. In the create_order_line function you mentioned, it generates a random between 1 and 5, but uses the same value for both quantity and quantity_allocated.

Do I understand correctly that we want the quantity to still be between 1 and 50, and have the quantity_allocated match that value?

Hey, we could entirely remove generating value for quantity_allocated field in the create_variant function. I don't think that this is particularly useful to anyone.

Okay. I'm gonna do that and put a pull request in.

I put the pull request in... I hope I did it right. I had a fork made and added the master as an upstream so that I could get my fork back up to the master... and then when I pushed to my branch it also pushed it to the original master.

I think a better solutions would be one that increases both quantity in stock _and_ quantity allocated by the total number used by orders. Otherwise stock numbers won't behave properly when fulfillment happens.

Was this page helpful?
0 / 5 - 0 ratings