summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-07-07 08:41:13 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-07-07 08:41:13 +0700
commit981d77b17338cf1a0fe2d83c69258a9f3cdebe0f (patch)
treeb7cc6c9a510372d0b82670abc81eac82a3b42161
parent8ae9c244aa06c07d3723cf7a330125bc743c7533 (diff)
Update product variant api response
Set stock to 1 when no stock available
-rw-r--r--indoteknik_api/models/product_product.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py
index a8502dbc..edf95a58 100644
--- a/indoteknik_api/models/product_product.py
+++ b/indoteknik_api/models/product_product.py
@@ -63,6 +63,8 @@ class ProductProduct(models.Model):
price_discount = flashsale_price
discount_percentage = flashsale_discount
+ stock = product_product.qty_stock_vendor
+ stock = stock if stock > 0 else 1
product_template = product_product.product_tmpl_id
data = {
'id': product_product.id,
@@ -78,7 +80,7 @@ class ProductProduct(models.Model):
'discount_percentage': discount_percentage,
'price_discount': price_discount
},
- 'stock': product_product.qty_stock_vendor,
+ 'stock': stock,
'weight': product_product.weight,
'attributes': [x.name for x in product_product.product_template_attribute_value_ids],
'manufacture' : self.api_manufacture(product_product)