summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/product_template.py1
-rwxr-xr-xindoteknik_custom/models/user_activity_log.py31
2 files changed, 32 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 5d34fbc8..114899e6 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -33,6 +33,7 @@ class ProductTemplate(models.Model):
web_price_sorting = fields.Float('Web Price Sorting', help='Hanya digunakan untuk sorting di web, harga tidak berlaku', default=0.0)
virtual_qty = fields.Float(string='Virtual Qty', default=0)
solr_flag = fields.Integer(string='Solr Flag', default=0)
+ search_rank = fields.Integer(string='Search Rank', default=0)
# def write(self, vals):
# if 'solr_flag' not in vals and self.solr_flag == 1:
diff --git a/indoteknik_custom/models/user_activity_log.py b/indoteknik_custom/models/user_activity_log.py
index 07079714..ab85d47f 100755
--- a/indoteknik_custom/models/user_activity_log.py
+++ b/indoteknik_custom/models/user_activity_log.py
@@ -1,4 +1,7 @@
from odoo import models, fields
+import logging, re
+
+_logger = logging.getLogger(__name__)
class UserActivityLog(models.Model):
@@ -9,8 +12,36 @@ class UserActivityLog(models.Model):
url = fields.Char(string="URL")
res_user_id = fields.Many2one("res.users", string="User")
email = fields.Char(string="Email")
+ update_product = fields.Boolean(string="Update Product")
def clean_activity_log(self):
self.env['user.activity.log'].search([
('email', 'not ilike', '%@%'),
]).unlink()
+
+ def update_rank_search(self):
+ activity_logs = self.env['user.activity.log'].search([
+ ('url', 'ilike', '%/shop/product/%'),
+ ('update_product', '=', False),
+ # ('url', 'not ilike', '%/shop/product/%google-ads-shopping'),
+ # ('id', '=', 211957)
+ ], limit=1000)
+
+ for activity_log in activity_logs:
+ _logger.info(activity_log.url)
+ strip_index = i = 0
+ for c in activity_log.url:
+ if c == '-':
+ strip_index = i
+ i += 1
+ _logger.info(activity_log.url[strip_index+1:len(activity_log.url)])
+ product_id = activity_log.url[strip_index+1:len(activity_log.url)]
+ if '#' in product_id:
+ continue
+ if any(ch.isalpha() for ch in product_id):
+ continue
+ template = self.env['product.template'].search([
+ ('id', '=', product_id)
+ ], limit=1)
+ template.search_rank += int(template.search_rank+1)
+ activity_log.update_product = True