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

Module: Discuss

Entity: mail.poll.option

Compute Method: _compute_number_of_votes

Inputs Method Outputs
count_by_option = dict(
            self.env["mail.poll.vote"]._read_group(
                [("option_id", "in", self.ids)], ["option_id"], ["__count"]
            )
        )
for option in self:
            option.number_of_votes = count_by_option.get(option, 0)

Back to entity