[FIX] website_blog: Prevent tags loading if no blogs
Steps to reproduce the bug: - Go to website app > configuration - Set the visibility of all the blog to Website A (So that it's not visible on Website B) - Go to the Blog menu of Website B - A traceback is triggered Problem: The `all_tags` function calls an SQL query to get the tags related to the website blog with a where condition based on the blog_id. But since there is no blog linked to the site. The request fails and an error is raised. Solution: Do not load the tags, if there is no blog for the website. Opw-2545315 closes odoo/odoo#72636 X-original-commit: 4d8fc86e4e6beb2171e3bebbabd532086d884d59 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com> Signed-off-by: Djamel Touati <DjamelTouati@users.noreply.github.com>
This commit is contained in:
@@ -116,7 +116,10 @@ class WebsiteBlog(http.Controller):
|
||||
step=self._blog_post_per_page,
|
||||
)
|
||||
|
||||
all_tags = blogs.all_tags(join=True) if not blog else blogs.all_tags().get(blog.id, request.env['blog.tag'])
|
||||
if not blogs:
|
||||
all_tags = request.env['blog.tag']
|
||||
else:
|
||||
all_tags = blogs.all_tags(join=True) if not blog else blogs.all_tags().get(blog.id, request.env['blog.tag'])
|
||||
tag_category = sorted(all_tags.mapped('category_id'), key=lambda category: category.name.upper())
|
||||
other_tags = sorted(all_tags.filtered(lambda x: not x.category_id), key=lambda tag: tag.name.upper())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user