diff options
Diffstat (limited to 'indoteknik_custom/models/user_activity_log.py')
| -rwxr-xr-x | indoteknik_custom/models/user_activity_log.py | 31 |
1 files changed, 31 insertions, 0 deletions
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 |
