Hey i have a report which opens up on odoo website but i also want to take print of it. Right now report is at url "\http://localhost:8069/purchase_comparison_chart/purchase_comparison/te00002-2" now i have added a button in it but i dont know what url to assign to it and exact python function for downloading pdf. Kindly give me some guidance. I shall be thankful
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
1
Balas
5828
Tampilan
Hi,
1- The value of your href must be a link to a controller like the below code:
<a role="button" class="btn btn-primary d-none d-md-inline-block" href="/shop/print" target="_blank" aria-label="Print" title="Print"><i class="fa fa-print"></i> Print</a>
2- After, create a controller like the following code :
@http.route(['/shop/print'], type='http', auth="public", website=True)
def print_saleorder(self, **kwargs):
sale_order_id = request.session.get('sale_last_order_id')
if sale_order_id:
pdf, _ = request.env.ref('sale.action_report_saleorder').sudo().render_qweb_pdf([sale_order_id])
pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', u'%s' % len(pdf))]
return request.make_response(pdf, headers=pdfhttpheaders)
else:
return request.redirect('/shop')
Best regards!
Thank you! very helpful
You're welcome!
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
How to create pdf report from website frontend?
Diselesaikan
|
|
2
Sep 21
|
6507 | |
|
7
Jan 20
|
9383 | ||
|
0
Nov 19
|
2524 | ||
|
0
Nov 19
|
4014 | ||
|
2
Jan 25
|
592 |