summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2022-11-16 09:37:31 +0700
committerIT Fixcomart <it@fixcomart.co.id>2022-11-16 09:37:31 +0700
commit96aa78d337428ab65cafc88480f78f7779c5ba47 (patch)
treefc8c7971febd8afa603d95eb448d6be29b680fed
parent33b9ec81f1ccd7d99da60c606e6bfce8d6627132 (diff)
Update product rating
-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