[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) <tde@openerp.com>
This commit is contained in:
Patrick Hoste
2020-01-31 12:38:33 +00:00
committed by Thibault Delavallée
parent f168703247
commit d9247094c2
+5 -1
View File
@@ -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)]