summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-10-11 15:23:21 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-10-11 15:23:21 +0700
commit1c09eab41878d452338d6b6a850550f03e8f1540 (patch)
treed5f36e49496dbffa4e22cec9cabfee65734f5e38
parent378e076fa40fd7de2f2755e6ff2873264b24cd70 (diff)
Update product_template.py
-rwxr-xr-xindoteknik_custom/models/product_template.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index ccbc9ff6..b1dcabb6 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -86,10 +86,13 @@ class ProductTemplate(models.Model):
('type', '=', 'product'),
('active', '=', True),
('last_calculate_rating', '=', False),
+ # ('id', '=', 22798),
], limit=10000)
+
for product in products:
# print("Calculate Rating Product ", product)
_logger.info("Calculate Rating Product %s" % product.id)
+ product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1)
rate = 0
if product.web_price:
rate += 1
@@ -100,6 +103,8 @@ class ProductTemplate(models.Model):
rate += 1
if product.website_description:
rate += 1
+ if product_variant.qty_stock_vendor > 0:
+ rate += 1
product.product_rating = rate
product.last_calculate_rating = current_time
@@ -108,8 +113,10 @@ class ProductTemplate(models.Model):
('active', '=', True),
('last_calculate_rating', '<', delta_time),
], limit=10000)
+
for product in products:
print("Calculate Rating Product OutOfDate", product)
+ product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1)
rate = 0
if product.web_price:
rate += 1
@@ -120,6 +127,8 @@ class ProductTemplate(models.Model):
rate += 1
if product.website_description:
rate += 1
+ if product_variant.qty_stock_vendor > 0:
+ rate += 1
product.product_rating = rate
product.last_calculate_rating = current_time