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

Module: eCommerce

Entity: crm.team

Compute Method: _compute_abandoned_carts

Inputs Method Outputs
  • id
website_teams = self.filtered(lambda team: team.website_ids)
abandoned_carts_data = self.env["sale.order"]._read_group(
            [
                ("is_abandoned_cart", "=", True),
                ("cart_recovery_email_sent", "=", False),
                ("team_id", "in", website_teams.ids),
            ],
            ["team_id"],
            ["amount_total:sum", "__count"],
        )
counts = {team.id: count for team, __, count in abandoned_carts_data}
amounts = {team.id: amount_total_sum for team, amount_total_sum, __ in abandoned_carts_data}
for team in self:
            team.abandoned_carts_count = counts.get(team.id, 0)
            team.abandoned_carts_amount = amounts.get(team.id, 0)

Back to entity