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

Module: Donation

Entity: res.partner

Compute Method: _compute_donation_count

Inputs Method Outputs
  • id
rg_res = self.env["donation.donation"]._read_group(
            [("partner_id", "in", self.ids), ("state", "=", "done")],
            groupby=["partner_id"],
            aggregates=["__count"],
        )
mapped_data = {partner.id: count for (partner, count) in rg_res}
for partner in self:
            partner.donation_count = mapped_data.get(partner.id, 0)

Back to entity