From 8cb3d124ec96b78872ebd0d0c969564249f15671 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 3 Feb 2023 10:39:38 +0700 Subject: [FIX] feature download invoice --- indoteknik_api/controllers/api_v1/download.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/download.py b/indoteknik_api/controllers/api_v1/download.py index 36f775b5..38225b85 100644 --- a/indoteknik_api/controllers/api_v1/download.py +++ b/indoteknik_api/controllers/api_v1/download.py @@ -16,9 +16,10 @@ class Download(controller.Controller): return result if len(result) > 0 else None @http.route(PREFIX + 'download/invoice/', auth='none', method=['GET']) - def download_invoice(self, **kw): - id = int(kw.get('id', 0)) - return request.render('account.report_invoice', {'id': id}) + def download_invoice(self, id): + id = int(id) + data = request.env['ir.actions.report'].sudo().search([('report_name', '=', 'account.report_invoice')])._render_qweb_pdf([id]) + return request.make_response(base64.b64decode(data[0]), [('Content-Type', 'application/pdf')]) @http.route(PREFIX + 'download/tax-invoice//', auth='none', method=['GET']) def download_tax_invoice(self, id, token): @@ -28,6 +29,7 @@ class Download(controller.Controller): if md5_by_id == token: attachment = self._get_attachment('account.move', 'efaktur_document', id) if attachment: + attachment = attachment[0] return request.make_response(base64.b64decode(attachment['datas']), [('Content-Type', attachment['mimetype'])]) return self.response('Dokumen tidak ditemukan', code=404) -- cgit v1.2.3