From d9247094c2940fef545ea7b5462eee3760676004 Mon Sep 17 00:00:00 2001 From: Patrick Hoste Date: Tue, 7 Jan 2020 12:31:17 +0000 Subject: [PATCH] [FIX] rating: fix search on rating Fix the access error you could get when filtering on ratings when not logged in or when the user has no rights to access ratings. How to reproduce: filter on channel review ratings in eLearning frontend when being anonymous le portal. As rating is a technical model, we have to first retrieve messages linked to that rating value and afterwards return a new domain used to build the final search. Task ID : 2167776 PR : #42847 closes odoo/odoo#44380 X-original-commit: 7a241e9c21046dababc2744dd94b0c47e2d8a931 Signed-off-by: Thibault Delavallee (tde) --- addons/rating/models/mail_message.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/rating/models/mail_message.py b/addons/rating/models/mail_message.py index 9de5cd20b58..015f21d333a 100644 --- a/addons/rating/models/mail_message.py +++ b/addons/rating/models/mail_message.py @@ -20,4 +20,8 @@ class MailMessage(models.Model): message.rating_value = mapping.get(message.id, 0.0) def _search_rating_value(self, operator, operand): - return [('rating_ids.rating', operator, operand)] + ratings = self.env['rating.rating'].sudo().search([ + ('rating', operator, operand), + ('message_id', '!=', False) + ]) + return [('id', 'in', ratings.mapped('message_id').ids)]