Saturday, January 27, 2018

How to change report.pdf in Odoo


from Delivery Report.pdf to PO00001.pdf



class report_controller(main.ReportController):
        @http.route(['/report/download'], type='http', auth="user")
        def report_download(self, data, token):
            order_obj = http.request.env['stock.picking']
            normalize_obj = unicodedata.normalize('NFKD', data).encode('ascii','ignore')
            if 'delivery_report' in normalize_obj:
                reportname = normalize_obj.split('/report/pdf/')[1].split('?')[0]
                reportname, docids = reportname.split('/')
                assert docids
                object = order_obj.browse(int(docids))
                response = super(report_controller, self).report_download(data, token)
                response.headers.set('Content-Disposition', 'attachment; filename=%s.pdf;' % object.origin)
                return response


fixed bug:
pls see on red

Reference:

No comments:

Post a Comment

free online comma separating tool

https://delim.co/#