summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-02-03 10:39:38 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-02-03 10:39:38 +0700
commit8cb3d124ec96b78872ebd0d0c969564249f15671 (patch)
tree52d6f6d8b8d546cd31ea046b0fc869c6aca7c48e /indoteknik_api/controllers/api_v1
parent9eb80e0aad8966c42fa721738986737b4040e0e4 (diff)
[FIX] feature download invoice
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/download.py8
1 files changed, 5 insertions, 3 deletions
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/<id>', 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/<id>/<token>', 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)