diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-05-05 15:23:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-05-05 15:23:50 +0700 |
| commit | d97277a0847bc57c0bc704c5ea62f75fadb461dc (patch) | |
| tree | bd0dbadd1e889c40a2af2bb74e9125a726fdfccf | |
| parent | f716974b222fdbaeb41ef95c391451e993b9825e (diff) | |
fix speed compute tag in leads
| -rwxr-xr-x | indoteknik_custom/models/crm_lead.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index b40bed6e..e7af4b1c 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -1,4 +1,7 @@ from odoo import fields, models, api +import logging + +_logger = logging.getLogger(__name__) class CrmLead(models.Model): @@ -54,16 +57,27 @@ class CrmLead(models.Model): # ('id', '=', 12523) ], limit=1000) for lead in leads: + _logger.info('processing tagged lead %s' % lead.id) input_tags = [] - if "Ada Quotation dari Website" in lead.name: - input_tags.append(1509) - lead.tag_ids = input_tags + if lead.order_id: + last_manufacture_id = 0 + for line in lead.order_id.order_line: + tag = self.env['crm.tag'].search([('name', 'ilike', line.product_id.product_tmpl_id.x_manufacture.x_name)], limit=1) + if tag and tag.id != last_manufacture_id: + last_manufacture_id = tag.id + input_tags.append(tag.id) + input_tags.append(1509) #Website hastag + lead.tag_ids = input_tags else: tags = self.env['crm.tag'].search([('id', '>', 0)]) for tag in tags: if tag.name.lower() in lead.body_html_lead.lower(): input_tags.append(tag.id) - lead.tag_ids = input_tags + if input_tags: + lead.tag_ids = input_tags + else: + input_tags.append(1510) #no tag + lead.tag_ids = input_tags if not lead.partner_id: continue |
