diff options
| -rwxr-xr-x | indoteknik_custom/models/crm_lead.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index 15ec4119..53ea176c 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import fields, models, api class CrmLead(models.Model): @@ -9,4 +9,27 @@ class CrmLead(models.Model): file_nib = fields.Binary(string="Nomor Induk Berusaha") file_tdp = fields.Binary(string="Tanda Daftar Perusahaan") file_siup = fields.Binary(string="Surat Izin Usaha Perdagangan") + body_html_lead = fields.Text('Body HTML', compute='compute_body_leads') + def compute_body_leads(self): + for lead in self: + mail_message = self.env['mail.message'].search([ + ('res_id', '=', lead.id), + ('model', '=', 'crm.lead'), + ('message_type', '=', 'email') + ], limit=1) + lead.body_html_lead = mail_message.body or '' + + def _update_tags_leads(self): + leads = self.env['crm.lead'].search([ + ('active', '=', True), + ('type', '=', 'lead'), + ('tag_ids', '=', False), + ], limit=1000) + for lead in leads: + tags = self.env['crm.tag'].search([('id', '>', 0)]) + input_tags = [] + for tag in tags: + if tag.name.lower() in lead.body_html_lead.lower(): + input_tags.append(tag.id) + lead.tag_ids = input_tags |
