Odoo Help

Niyas Raphy
On 7/16/17, 4:22 AM

Got the solution,

Printed the report by giving a href to the button like this,

<a t-attf-href="'/report/pdf/account.report_invoice/%s' % i.id">
<button type="button" class="btn btn-primary btn-md o_website_form_send">Print Invoice</button>

In the i.id i have the id of the invoice.
This is the format,

To print the report from the  controller,

@http.route('/school/card', methods=['POST', 'GET'], csrf=False, type='http', auth="user", website=True)
def print_id(self, **kw):
student_id = kw['stud_id']
if student_id:
pdf = request.env['report'].sudo().get_pdf([student_id], 'module_name.report_name', data=None)
pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
return request.make_response(pdf, headers=pdfhttpheaders)

return request.redirect('/')
Yenthe Van Ginneken
On 7/25/18, 7:31 AM

Or in another way by directly calling the id in #{record.id} like this:

<a t-attf-href="/report/pdf/account.report_invoice/#{i.id}">

About This Community

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

Question tools

1 follower(s)


Asked: 7/16/17, 3:59 AM
Seen: 2148 times
Last updated: 1/8/19, 8:46 AM