[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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user