[FIX] website_blog: avoid traceback if tag has been deleted

Before this commit, if you have a link with a tag that doesn't exists anymore,
you will have a traceback because you try to access to a unexisting record.

odoo.exceptions.MissingError:
('Record does not exist or has been deleted.\n\n(Records: [3], User: 2)', None)

Now, we filter on existing tag before to access a field.

X-original-commit: 54b45e5c287138a87a0b04ce4f301ea6893b9223
This commit is contained in:
Jeremy Kersten
2020-02-21 12:30:15 +00:00
parent d020dd89b5
commit 01028b1cf3
+1 -1
View File
@@ -69,7 +69,7 @@ class WebsiteBlog(http.Controller):
active_tag_ids = tags and [unslug(tag)[1] for tag in tags.split(',')] or []
if active_tag_ids:
fixed_tag_slug = ",".join(slug(t) for t in request.env['blog.tag'].browse(active_tag_ids))
fixed_tag_slug = ",".join(slug(t) for t in request.env['blog.tag'].browse(active_tag_ids).exists())
if fixed_tag_slug != tags:
return request.redirect(request.httprequest.full_path.replace("/tag/%s/" % tags, "/tag/%s/" % fixed_tag_slug, 1), 301)