Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

(Odoo v11) Print button on website to print the report in pdf.

Subscribe

Get notified when there's activity on this post

This question has been flagged
pdfreportingv11websiteodoo
7 Replies
10768 Views
Avatar
Abdullah

i have a purchase comparison chart which matches the Bids amount . It shows the comparison in odoo website but client also want to save that report. I find no way of downloading that report. I am thinking of a button on the website screen which can the download the report. I need some guidance Please help  

0
Avatar
Discard
Avatar
Nikhil kushwaha
Best Answer

XML 

<a t-att-href="/report/new/">
  <button type="button" class="btn btn-primary btn-md ">Print Report</button>
</a>

Python 


@http.route('/report/new/', methods=['POST', 'GET'], csrf=False, type='http', auth="user", website=True)
def print_id(self, **kw):
    pdf, _ = request.env.ref('Model_Name.Action_Name')\.sudo().render_qweb_pdf([int(purchase_id)])
    pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf)),('Content-Disposition', 'catalogue' + '.pdf;')]
    return request.make_response(pdf, headers=pdfhttpheaders)



0
Avatar
Discard
Abdullah
Author

hey thanks for replying. one question, you are using purchase_id for?

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

Follow the steps below

create a button:(xml)

<a t-attf-href="'/report/type_of_the_report/module_name.template_name/%s' % id">
    <button type="button" class="btn btn-primary btn-md o_website_form_send">Print Report</button>
</a>

in controller:(py)

@http.route('your custom route', methods=['POST', 'GET'], csrf=False, type='http', auth="user", website=True)
def print_id(self, **kw):
record_id = kw['rec_id']
if record_id:
pdf = request.env['report'].sudo().get_pdf([record_id], 'module_name.report_name', data=None)
pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
return request.make_response(pdf, headers=pdfhttpheaders)
else:
return request.redirect('/')
3
Avatar
Discard
Abdullah
Author

Thank you so much for replying!

when i follow the above line of code and press the button it takes me to another page and says "404 page not found".

I have 3 confusions if you can please help

1) should i create another class in the controller for the above http.route?As i already have a class with a route which displays my report.

2)For web reports , do we have to set it up same like pdf reports? like the following

<report

id="account_invoices"

model="account.invoice"

string="Invoices"

report_type="qweb-pdf"

name="account.report_invoice"

file="account.report_invoice"

attachment_use="True"

attachment="(object.state in ('open','paid')) and

('INV'+(object.number or '').replace('/','')+'.pdf')"

/>

3) On what basis we define a route? shoould it be same of the button path?

It will be very helpful if you could just explain as its my first time working with controller. i'll be very thankful!

Cybrosys Techno Solutions Pvt.Ltd

You can refer the following module for the clarification in which we are added the option for printing the pdf catalogue of a product from the website

https://www.odoo.com/apps/modules/12.0/product_catalogue/

Abdullah
Author

ok thanks :)

Abdullah
Author

That download catelogue button in your module is not working giving internal server error and this is what i have in the log

AttributeError: 'report.product_catalogue.report_product_catalog' object has no attribute 'get_report_values'

Cybrosys Techno Solutions Pvt.Ltd

This module is available for odoo 12, i think you are trying to install this module on odoo v11

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
odoov11 what is the use of window.print(). Solved
function reporting v11 website odoo
Avatar
Avatar
1
Nov 19
3847
Odoo qweb report download on odoo website using a button Solved
reporting website odoo
Avatar
Avatar
2
Oct 17
14102
How to assign a url to a download button on odoo website(v11) Solved
purchase pdf reporting url website
Avatar
Avatar
1
Aug 22
7081
How to create pdf report from website frontend? Solved
pdf form reporting website v14
Avatar
Avatar
2
Sep 21
7985
Odoo website iframe youtube video not showing
website odoo
Avatar
1
Nov 25
3324
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now