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

Module: Mass mailing on lead / opportunities

Entity: mailing.mailing

Compute Method: _compute_crm_lead_count

Inputs Method Outputs
  • source_id
  • source_id.ids
  • source_id.id
lead_data = self.env['crm.lead'].with_context(active_test=False).sudo()._read_group(
            [('source_id', 'in', self.source_id.ids)],
            ['source_id'], ['__count'],
        )
mapped_data = {source.id: count for source, count in lead_data}
for mass_mailing in self:
            mass_mailing.crm_lead_count = mapped_data.get(mass_mailing.source_id.id, 0)

Back to entity