question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stock.DoesNotExist after ProductVariant Creation

See original GitHub issue

What I’m trying to achieve

To test the system for the first time by creating product variants. I got an error of saleor.warehouse.models.Stock.DoesNotExist when I was creating ProductVariant for an existing product.

Steps to reproduce the problem

  1. I cloned Saleor repository from master with merged #4986 PR.
  2. I cloned Saleor Dashboard from master
  3. I have set up both saleor and saleor-dashboard
  4. I created 2 attributes, 1 product type, 1 category.
  5. I created a Product with the above options
  6. I created for this existing product 6 product variants and then got an error

What I expected to happen

I hope ProductVariants had to be created without any errors, because if I had to create warehouse first, then this feature needed to be in saleor-dashboard, but I could not find it. What is more interesting, I guess according to the migration inside warehouse app, at least one warehouse needed to be created and but none was created. I was also curious about thoughts of @szewczykmira:

In my approach - we will create warehouse if a) there are some product variants created and b) there is no other warehouse that supports all shipping zones.

Did that mean that when migrations are just being executed for the first time, no warehouse is going to be created? if yes, then it means that there may not be warehouse object in the system at all and it implies that there will not be stock object too. Then:

class ProductVariant(CountableDjangoObjectType, MetadataObjectType):
     ...
    def resolve_stock_quantity(root: models.ProductVariant, info):
        country = info.context.country
        try:
            stock = stock_models.Stock.objects.get_variant_stock_for_country(
                country, root
            )
        except stock_models.Stock.DoesNotExist:
            return 0
        return get_available_quantity_for_customer(stock)
    ...
    def resolve_quantity_allocated(root: models.ProductVariant, info):
        country = info.context.country
        stock = stock_models.Stock.objects.get_variant_stock_for_country(country, root)
        return stock.quantity_allocated

Why there is try-except in the first function, but there is no try-except in the second function? I am sorry if I was not clear about the error, and please let me know if I need to explain it more details

Screenshots

Screenshot from 2020-01-21 01-20-54 Screenshot from 2020-01-21 01-22-02

System information Operating system: Ubuntu 18.04 Python: 3.8 Django: 2.2.9 PostgreSQL: 12.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
maarcingebalacommented, Jan 21, 2020

Thanks for opening the issue @bedilbek. We’re working on a fix for this and for updating stock quantity with current mutations. Dashboard UI for this entire feature is ready and we’re going to start building it in our next sprint which starts at the end of January.

2reactions
szewczykmiracommented, Jan 21, 2020

Hi,

Did that mean that when migrations are just being executed for the first time, no warehouse is going to be created?

Exactly, creating warehouse happens only when there is existing product variant and there are stocks we need to migrate to the new model.

As you’ve noticed there are no warehouse/stock options in saleor-dashboard and this feature will be introduced there (but I’m not sure exactly when that will happen).

As for now - I’m working on a temporary fix - creating a Stock object (and warehouse) when there is none in the database.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Odoo - Field `product_variant_count` does not exist
I have created a custom model called Product_Videos that will hold multiple video for one product, Here is my model : from odoo...
Read more >
"Conversion does not exist" error message upon confirming...
"Conversion does not exist" error message upon confirming a purchase order with product variant UOM in the absence of stranded UOM conversion ...
Read more >
Products | HTTP API | commercetools Composable Commerce
Indicates whether a Product Variant is in stock in a specified Channel. restockableInDays ​. Int​. Number of days to restock ...
Read more >
Error on functions in queue: “Session does not exist in a ...
In this case there's at least one obvious suspect line: Craft::$app->session->setError('Lightspeed....); Indeed there's more than one of these.
Read more >
Inventory : Products / Master Data: Product Variants - hibou.io
In the Product section, enable Variants. When you're ready, click Save. Creating Variants. To create a product variant, navigate to Products ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found