Skip to content
Snippets Groups Projects
Commit 8e7cfb64 authored by std-odoo's avatar std-odoo
Browse files

[IMP] crm(_iap_lead_enrich): correctly enable / disable the enrich CRON


Purpose
=======
The parameter "lead_enrich_auto" enable or disable the enrich CRON.

This is done in an onchange and so, if we enable manually the CRON, the
change will not be reflected on the parameter.

Task 2443338

closes odoo/odoo#65007

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent 2dd697fd
Branches
Tags
No related merge requests found
......@@ -7,10 +7,15 @@ from odoo import api, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
@api.onchange('lead_enrich_auto')
def _onchange_cron_lead_enrich(self):
""" change the active status of the cron according to the settings"""
if self.module_crm_iap_lead_enrich == True:
cron = self.sudo().with_context(active_test=False).env.ref('crm_iap_lead_enrich.ir_cron_lead_enrichment')
if cron:
cron.active = self.lead_enrich_auto != 'manual'
@api.model
def get_values(self):
values = super(ResConfigSettings, self).get_values()
cron = self.sudo().with_context(active_test=False).env.ref('crm_iap_lead_enrich.ir_cron_lead_enrichment', raise_if_not_found=False)
values['lead_enrich_auto'] = 'auto' if cron and cron.active else 'manual'
return values
def set_values(self):
super(ResConfigSettings, self).set_values()
cron = self.sudo().with_context(active_test=False).env.ref('crm_iap_lead_enrich.ir_cron_lead_enrichment', raise_if_not_found=False)
if cron:
cron.active = self.lead_enrich_auto == 'auto'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment