From c3a81c6c7eebe1c2a42d01ac35f541cefd2c8f0d Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 14 May 2019 11:17:45 +0000 Subject: [PATCH] [FIX] website_forum, website_slides: correctly check if is admin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit and since 2f7c03d9ca580, the admin user has not ID=1 anymore. Thus, some old condition were not doing what they were expected to. Firstly, the admin was not considered as such on the forum, and if its karma points were not high enough, it would not be possible to do anything for the admin. Note that it was fixed in saas-12.1 with 1dac4131300 Secondly, some _search functions would not return a truthy value anymore. closes odoo/odoo#33359 Signed-off-by: Jérémy Kersten (jke) --- addons/website_forum/models/forum.py | 7 ++++--- addons/website_slides/models/slides.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 6c22f09d32f..df09356a9aa 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -288,10 +288,11 @@ class Post(models.Model): operator = operator == "=" and '!=' or '=' value = True - if self._uid == SUPERUSER_ID: + user = self.env.user + # Won't impact sitemap, search() in converter is forced as public user + if user._is_admin(): return [(1, '=', 1)] - user = self.env['res.users'].browse(self._uid) req = """ SELECT p.id FROM forum_post p @@ -379,7 +380,7 @@ class Post(models.Model): @api.multi def _get_post_karma_rights(self): user = self.env.user - is_admin = user.id == SUPERUSER_ID + is_admin = user._is_admin() # sudoed recordset instead of individual posts so values can be # prefetched in bulk for post, post_sudo in pycompat.izip(self, self.sudo()): diff --git a/addons/website_slides/models/slides.py b/addons/website_slides/models/slides.py index ab8494d1212..0261d04725d 100644 --- a/addons/website_slides/models/slides.py +++ b/addons/website_slides/models/slides.py @@ -121,7 +121,8 @@ class Channel(models.Model): if not value: operator = operator == "=" and '!=' or '=' - if self._uid == SUPERUSER_ID: + # Won't impact sitemap, search() in converter is forced as public user + if self.env.user._is_admin(): return [(1, '=', 1)] # Better perfs to split request and use inner join that left join