diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-07 10:39:24 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-07 10:39:24 +0700 |
| commit | d6501fd1c30eab8686e87595327ee2887e587a49 (patch) | |
| tree | df97bc05c533579cbb26961083d78b5bbcce8cd7 | |
| parent | 97b5798df4cba856d98715cea095fda414f434a9 (diff) | |
Update product_template.py
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index d1a5867f..49f903e4 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -45,25 +45,36 @@ class ProductTemplate(models.Model): @api.model def _calculate_rating_product(self): - # TODO add filter last calculation date time - # current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') current_time = datetime.now() - current_time = current_time - timedelta(days=60) + delta_time = current_time - timedelta(days=60) + current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') + delta_time = delta_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 + if product.web_price: + rate += 1 + if product.have_promotion_program: + rate += 1 + if product.image_128: + rate += 1 + product.product_rating = rate + product.last_calculate_rating = current_time + + products = self.env['product.template'].search([ + ('type', '=', 'product'), + ('active', '=', True), + ('last_calculate_rating', '<', delta_time), + ], limit=5000) + for product in products: + print("Calculate Rating Product OutOfDate", product) rate = 0 if product.web_price: rate += 1 |
