[FIX] crm_iap_enrich: correctly save 'Enrich lead automatically' setting

## Steps to reproduce
1. navigate to Settings -> CRM -> Lead Enrichment section
2. change the Lead Enrichment option to "Enrich leads on demand only"
3. click Save button
4. wait for system to save and refresh.

You should see that the change you made was not saved.

opw-3063639

closes odoo/odoo#106891

X-original-commit: 0803775e4a156aa6988453edbbaf799730c996b2
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
This commit is contained in:
Nshimiyimana Séna
2022-11-30 15:06:30 +01:00
parent 6d985bbae5
commit ad1c11b196
2 changed files with 14 additions and 1 deletions
@@ -17,5 +17,5 @@ class ResConfigSettings(models.TransientModel):
def set_values(self):
super().set_values()
cron = self.sudo().with_context(active_test=False).env.ref('crm_iap_enrich.ir_cron_lead_enrichment', raise_if_not_found=False)
if cron and cron.active != self.lead_enrich_auto == 'auto':
if cron and cron.active != (self.lead_enrich_auto == 'auto'):
cron.active = self.lead_enrich_auto == 'auto'
@@ -56,3 +56,16 @@ class TestLeadEnrich(TestCrmCommon, MockIAPEnrich):
for lead in leads:
self.assertEqual(lead.street, False)
def test_lead_enrich_auto_setting(self):
cron = self.env.ref('crm_iap_enrich.ir_cron_lead_enrichment')
config = self.env['res.config.settings'].create({
'lead_enrich_auto': 'manual',
})
config.execute()
self.assertFalse(cron.active)
config.write({'lead_enrich_auto': 'auto'})
config.execute()
self.assertTrue(cron.active)