diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-06 14:55:30 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-06 14:55:30 +0700 |
| commit | 97b5798df4cba856d98715cea095fda414f434a9 (patch) | |
| tree | 5397c4bf8b2782dfc285f0037843384a5abb4e07 /indoteknik_custom/models | |
| parent | e2854b141338728d9d720fa9bd97dd44ab08d806 (diff) | |
Update product_template.py and product_template.xml
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 041fcd61..d1a5867f 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -1,5 +1,5 @@ from odoo import fields, models, api -from datetime import datetime +from datetime import datetime, timedelta class ProductTemplate(models.Model): @@ -46,10 +46,25 @@ class ProductTemplate(models.Model): @api.model def _calculate_rating_product(self): # TODO add filter last calculation date time - products = self.env['product.template'].search([('type', '=', 'product'),('active', '=', True)], limit=1) + # current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + current_time = datetime.now() + current_time = current_time - timedelta(days=60) + current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') + + products = self.env['product.template'].search([ + ('type', '=', 'product'), + ('active', '=', True), + "|" + ('last_calculate_rating', '!=', False), + ('last_calculate_rating', '<', current_time), + # ('x_manufacture', '=', 10) + # ('id', '=', 33627) + ], limit=5000) for product in products: + print(product.last_calculate_rating) + print("Calculate Rating Product ", product) + # print(product.image_128) rate = 0 - test = product.image_128 if product.web_price: rate += 1 if product.have_promotion_program: @@ -57,7 +72,6 @@ class ProductTemplate(models.Model): if product.image_128: rate += 1 product.product_rating = rate - current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') product.last_calculate_rating = current_time |
