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

View 17.0 View 20.0
Inputs Method Outputs
  • source_id
  • source_id.id
  • id
leads_data = self.env['crm.lead'].with_context(active_test=False).sudo()._read_group(
-             [('source_id', 'in', self.mapped('source_id').ids)], ['source_id'], ['__count'])
- mapped_leads = {source.id: count for source, count in leads_data}
+             [('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(script.source_id.id, 0)
+             script.lead_count = mapped_leads.get(f'{script._name},{script.id}', 0)
  • lead_count

Back to entity