[FIX] website_forum, website_slides: correctly check if is admin
Before this commit and since2f7c03d9ca, 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 with1dac413130Secondly, some _search functions would not return a truthy value anymore. closes odoo/odoo#33359 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
@@ -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()):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user