Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


website_slide won't allow public download

Tech Support
on 6/7/16, 3:48 PM 194 views

In my "Library" on my website I can navigate to a particular slide but when I hit the download button it prompts me to login. The line in the code looks like this:

@http.route('''/slides/slide/<model("slide.slide", "[('channel_id.can_see', '=', True), ('download_security', '=', 'public')]"):slide>/download''', type='http', auth="public", website=True)
def slide_download(self, slide):
if slide.download_security == 'public' or (slide.download_security == 'user' and request.session.uid):
filecontent = base64.b64decode(slide.datas)
disposition = 'attachment; filename=%s.pdf' % werkzeug.urls.url_quote(slide.name)
return request.make_response(
[('Content-Type', 'application/pdf'),
('Content-Length', len(filecontent)),
('Content-Disposition', disposition)])
elif not request.session.uid and slide.download_security == 'user':
return werkzeug.utils.redirect('/web?redirect=/slides/slide/%s' % (slide.id))
return request.website.render("website.403")

I put in a pdb and found that whether I'm logged in or not the slide.download_security is always equal to 'user'. I've tried all combinations of removing things but usually just that results in the loss of my download button. However, if I navigate directly to the /slides/slide/#/download url it downloads. So I guess I know that is works.

How can I allow the public to download these documents without having to be logged in and still maintain my download button?

Thanks for your help!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 6/7/16, 3:48 PM
Seen: 194 times
Last updated: 6/8/16, 1:50 AM