Right now, when we choose to automatically enrich the leads from CRM settings, it activates a cron to periodically enrich the leads using IAP service. This commit improves the behavior by enriching the leads after the records creation using cron trigger. That way it is done nearly after creation and user gets enrich information sooner. To make it clear to users, the description for 'auto' mode is improved to 'Enrich all leads on creation'. Also, now we select 'auto' mode by default instead of 'manual', and display 'Enrich' button on form view irrespective of the selected mode (if lead meets certain conditions) unlike before. Rest of the behavior is still same as before. For example, we still have server action which can enrich the selected leads in batch, which is useful if there are existing leads before we enable 'Lead Enrichment' feature. Task-2269743 Part-of: odoo/odoo#60605
15 lines
478 B
Python
15 lines
478 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from . import models
|
|
|
|
from odoo.api import Environment, SUPERUSER_ID
|
|
|
|
|
|
def _synchronize_cron(cr, registry):
|
|
env = Environment(cr, SUPERUSER_ID, {'active_test': False})
|
|
cron = env.ref('crm_iap_enrich.ir_cron_lead_enrichment')
|
|
if cron:
|
|
config = env['ir.config_parameter'].get_param('crm.iap.lead.enrich.setting', 'auto')
|
|
cron.active = config == 'auto'
|