diff options
| author | Romain Derie <rde@odoo.com> | 2019-05-14 11:17:45 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2019-05-14 11:17:45 +0000 |
| commit | c3a81c6c7eebe1c2a42d01ac35f541cefd2c8f0d (patch) | |
| tree | ae6ea1c8476de669ede2ae67fb39a70481590ee2 | |
| parent | c92b0ce3036dde24b638bb3fb5dd89d7afbd759f (diff) | |
[FIX] website_forum, website_slides: correctly check if is admin
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) <jke@openerp.com>
| -rw-r--r-- | addons/website_forum/models/forum.py | 7 | ||||
| -rw-r--r-- | 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 |
