Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: CRM Livechat

Entity: chatbot.script

Compute Method: _compute_lead_count

Inputs Method Outputs
  • id
leads_data = self.env['crm.lead'].with_context(active_test=False).sudo()._read_group(
            [('utm_reference', 'in', [f'{script._name},{script.id}' for script in self])],
            ['utm_reference'], ['__count']
        )
mapped_leads = dict(leads_data)
for script in self:
            script.lead_count = mapped_leads.get(f'{script._name},{script.id}', 0)

Back to entity