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

Compute Method: _compute_winning_option_ids

View 20.0
Inputs Method Outputs
  • option_ids
+ ongoing_polls = self.filtered(lambda poll: not poll.end_message_id)
+ ongoing_polls.winning_option_id = None
+ for poll in self - ongoing_polls:
+             max_vote = max(option.vote_percentage for option in poll.option_ids)
+             winners = [
+                 option
+                 for option in poll.option_ids
+                 if option.vote_percentage == max_vote and option.vote_percentage > 0
+             ]
+             poll.winning_option_id = winners[0] if len(winners) == 1 else None
  • winning_option_id

Back to entity