Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Check availabilty per country - currently use DEFAULT_COUNTRY
Mira Szewczykf60d03528ce2
diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.pyindex e5f8cf36f6..58f63dc1a9 100644--- a/saleor/data_feeds/google_merchant.py+++ b/saleor/data_feeds/google_merchant.py@@ -13,6 +13,7 @@ from ..core.taxes import zero_moneyfrom ..discount import DiscountInfofrom ..discount.utils import fetch_discountsfrom ..product.models import Attribute, AttributeValue, Category, ProductVariant+from ..stock.availability import is_variant_in_stockCATEGORY_SEPARATOR = " > "@@ -144,7 +145,7 @@ def item_image_link(item: ProductVariant, current_site):def item_availability(item: ProductVariant):- if item.quantity_available:+ if is_variant_in_stock(item, settings.DEFAULT_COUNTRY):return "in stock"return "out of stock"diff --git a/tests/test_emails.py b/tests/test_emails.pyindex 0ed80b1683..9f6999d0c7 100644--- a/tests/test_emails.py+++ b/tests/test_emails.py@@ -154,7 +154,7 @@ def test_send_confirmation_emails_without_addresses_for_payment(add_variant_to_order(order, digital_content.product_variant, quantity=1)order.shipping_address = Noneorder.shipping_method = None- order.billing_address = None+ order.billing_address = addressorder.save(update_fields=["shipping_address", "shipping_method", "billing_address"])emails.send_payment_confirmation(order.pk)diff --git a/tests/test_order_actions.py b/tests/test_order_actions.pyindex 6e66aef7ae..7b5bff9cd1 100644--- a/tests/test_order_actions.py+++ b/tests/test_order_actions.py@@ -17,15 +17,17 @@ from saleor.order.actions import (from saleor.order.models import Fulfillmentfrom saleor.payment import ChargeStatus, PaymentErrorfrom saleor.product.models import DigitalContent+from saleor.stock.models import Stockfrom .utils import create_image@pytest.fixture-def order_with_digital_line(order, digital_content, variant, site_settings):+def order_with_digital_line(order, digital_content, stock, site_settings):site_settings.automatic_fulfillment_digital_products = Truesite_settings.save()+ variant = stock.product_variantvariant.digital_content = digital_contentvariant.digital_content.save()@@ -165,12 +167,13 @@ def test_fulfill_order_line(order_with_lines):line = order.lines.first()quantity_fulfilled_before = line.quantity_fulfilledvariant = line.variant- stock_quantity_after = variant.quantity - line.quantity+ stock = Stock.objects.get(product_variant=variant)+ stock_quantity_after = stock.quantity - line.quantityfulfill_order_line(line, line.quantity)- variant.refresh_from_db()- assert variant.quantity == stock_quantity_after+ stock.refresh_from_db()+ assert stock.quantity == stock_quantity_afterassert line.quantity_fulfilled == quantity_fulfilled_before + line.quantity@@ -190,14 +193,15 @@ def test_fulfill_order_line_without_inventory_tracking(order_with_lines):variant = line.variantvariant.track_inventory = Falsevariant.save()+ stock = Stock.objects.get(product_variant=variant)# stock should not change- stock_quantity_after = variant.quantity+ stock_quantity_after = stock.quantityfulfill_order_line(line, line.quantity)- variant.refresh_from_db()- assert variant.quantity == stock_quantity_after+ stock.refresh_from_db()+ assert stock.quantity == stock_quantity_afterassert line.quantity_fulfilled == quantity_fulfilled_before + line.quantity