summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_api/models/product_template.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/indoteknik_api/models/product_template.py b/indoteknik_api/models/product_template.py
index b616a773..e140b326 100644
--- a/indoteknik_api/models/product_template.py
+++ b/indoteknik_api/models/product_template.py
@@ -21,13 +21,24 @@ class ProductTemplate(models.Model):
'categories': self.api_categories(product_template),
}
if with_detail:
+ rate = 0
+ if data['lowest_price']['price'] > 0:
+ rate += 1
+ if product_template.have_promotion_program:
+ rate += 1
+ if product_template.image_128:
+ rate += 1
+ if product_template.website_description:
+ rate += 1
+ if product_template.qty_stock_vendor > 0:
+ rate += 1
data_with_detail = {
'image': base_url + 'api/image/product.template/image_512/' + str(product_template.id) if product_template.image_512 else '',
'display_name': product_template.display_name,
'variants': [self.env['product.product'].api_single_response(variant) for variant in product_template.product_variant_ids],
'description': product_template.website_description or '',
'solr_flag': product_template.solr_flag,
- 'product_rating': product_template.product_rating,
+ 'product_rating': rate,
}
data.update(data_with_detail)
return data