summaryrefslogtreecommitdiff
path: root/indoteknik_api/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_api/models')
-rw-r--r--indoteknik_api/models/product_product.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py
index 334b58c5..fb485bae 100644
--- a/indoteknik_api/models/product_product.py
+++ b/indoteknik_api/models/product_product.py
@@ -31,6 +31,8 @@ class ProductProduct(models.Model):
def v2_api_single_response(self, product_product):
product_template = product_product.product_tmpl_id
+ stock = product_product.qty_stock_vendor
+ stock = 1 if stock == 0 else stock
data = {
'id': product_product.id,
'parent': {
@@ -41,7 +43,7 @@ class ProductProduct(models.Model):
'code': product_product.default_code or '',
'name': product_product.display_name,
'price': product_product.calculate_website_price(),
- '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)
@@ -82,6 +84,13 @@ class ProductProduct(models.Model):
if price[discount_key] > 0: discount_percentage = price[discount_key]
if price[price_key] > 0: price_discount = price[price_key]
+ flashsale = self._get_flashsale_price()
+ flashsale_price = flashsale['flashsale_price']
+ flashsale_discount = flashsale['flashsale_discount']
+ if flashsale_price > 0 and flashsale_price < price_discount:
+ price_discount = flashsale_price
+ discount_percentage = flashsale_discount
+
return {
'price': self._get_website_price_exclude_tax(),
'discount_percentage': discount_percentage,