Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Rename method checking product availability by stock quantity to avoid clashing with available_on field
Marcin Gębala924a557c22ab
diff --git a/saleor/product/models/base.py b/saleor/product/models/base.pyindex 88b7ca2783..f6312c63fe 100644--- a/saleor/product/models/base.py+++ b/saleor/product/models/base.py@@ -132,8 +132,8 @@ class Product(models.Model, ItemRange):admin_get_price_max.short_description = pgettext_lazy('Product admin page', 'Maximum price')- def is_available(self):- return any(variant.is_available() for variant in self)+ def is_in_stock(self):+ return any(variant.is_in_stock() for variant in self)@python_2_unicode_compatible@@ -198,8 +198,8 @@ class ProductVariant(models.Model, Item):def is_shipping_required(self):return True- def is_available(self):- return any([stock_item.is_available() for stock_item in self.stock.all()])+ def is_in_stock(self):+ return any([stock_item.quantity > 0 for stock_item in self.stock.all()])def get_attribute(self, pk):return self.attributes.get(str(pk))@@ -227,9 +227,6 @@ class Stock(models.Model):def __str__(self):return "%s - %s" % (self.variant.name, self.location)- def is_available(self):- return self.quantity > 0-@python_2_unicode_compatibleclass ProductAttribute(models.Model):diff --git a/saleor/product/templates/category/index.html b/saleor/product/templates/category/index.htmlindex 74e91bf8dc..75ba2ce324 100644--- a/saleor/product/templates/category/index.html+++ b/saleor/product/templates/category/index.html@@ -23,7 +23,7 @@</a>{% endif %}<h3><a href="{{ product.get_absolute_url }}">{{ product }}</a></h3>- {% if product.is_available %}+ {% if product.is_in_stock %}{% with price_range=product|discounted_price_range:request.discounts undiscounted=product.get_price_range %}{% with discount=undiscounted.min_price|price_difference:price_range.min_price %}<h4>diff --git a/saleor/product/templates/product/details.html b/saleor/product/templates/product/details.htmlindex d23fd06f37..0ccb2a99bd 100644--- a/saleor/product/templates/product/details.html+++ b/saleor/product/templates/product/details.html@@ -23,7 +23,7 @@{{ product }}</h1>- {% if product.is_available %}+ {% if product.is_in_stock %}{% with price_range=product|discounted_price_range:request.discounts undiscounted=product.get_price_range %}{% with discount=undiscounted.min_price|price_difference:price_range.min_price %}<p class="lead" itemprop="offers" itemscope itemtype="http://schema.org/Offer"@@ -49,7 +49,7 @@<hr></div>- {% if product.is_available %}+ {% if product.is_in_stock %}{% block orderform %}<form role="form" class="product-form form-vertical" method="post" action=".">{% csrf_token %}