Skip to content

Commit

Permalink
[FIX] mail: block negative search for need_moderation
Browse files Browse the repository at this point in the history
Other operators can only cause nonsensical results, while causing
useless slow queries. This is only really meant as a shortcut for
getting messages to moderate.
  • Loading branch information
odony committed Sep 19, 2018
1 parent 97dbdc4 commit ec4f7bc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions addons/mail/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,14 @@ def _compute_need_moderation(self):

@api.model
def _search_need_moderation(self, operator, operand):
if operator == '=' and operand:
if operator == '=' and operand is True:
return ['&', '&',
('moderation_status', '=', 'pending_moderation'),
('model', '=', 'mail.channel'),
('res_id', 'in', self.env.user.moderation_channel_ids.ids)]
return ['|', '|',
('moderation_status', '!=', 'pending_moderation'),
('model', '!=', 'mail.channel'),
('res_id', 'not in', self.env.user.moderation_channel_ids.ids)]

# no support for other operators
return ValueError(_('Unsupported search filter on moderation status'))

#------------------------------------------------------
# Notification API
Expand Down

0 comments on commit ec4f7bc

Please sign in to comment.