From bcbbee411f50944ab035b1b9bbeaa9494f2a940a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 29 May 2024 10:45:34 +0200 Subject: [PATCH] fix: refs #7498 Download invoice out error --- forms/ecomerce/invoices/index.js | 29 ++++++++--------------------- forms/ecomerce/invoices/ui.xml | 7 ++++--- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/forms/ecomerce/invoices/index.js b/forms/ecomerce/invoices/index.js index 5c0960b9..4ba0162e 100644 --- a/forms/ecomerce/invoices/index.js +++ b/forms/ecomerce/invoices/index.js @@ -3,30 +3,17 @@ import './style.scss'; export default new Class({ Extends: Hedera.Form, Template: require('./ui.xml'), - - donwloadRenderer(column, invoice) { - var invoiceId = invoice.$.id; - if (invoice.$.hasPdf && invoiceId) { - var params = { - srv: 'rest:dms/invoice', - invoice: invoiceId, - access_token: this.conn.token - }; + onDownloadClick(column, value, row) { + var model = this.$.invoices; + var hasPdf = model.get(row, 'hasPdf'); + var id = model.get(row, 'id'); - Object.assign(column, { - tip: _('Download PDF'), - disabled: false, - icon: 'download', - href: '?'+ Vn.Url.makeUri(params) - }); + if (hasPdf && id) { + let params = Vn.Url.makeUri({ access_token: this.conn.token }); + window.open(`/api/InvoiceOuts/${id}/download?${params}`); } else - Object.assign(column, { - tip: _('Request the invoice to your salesperson'), - disabled: true, - icon: 'warning', - href: null - }); + Htk.Toast.showWarning(_('Request the invoice to your salesperson')); } }); diff --git a/forms/ecomerce/invoices/ui.xml b/forms/ecomerce/invoices/ui.xml index aa6244a0..30bf2f93 100644 --- a/forms/ecomerce/invoices/ui.xml +++ b/forms/ecomerce/invoices/ui.xml @@ -6,7 +6,7 @@ - + SELECT id, ref, issued, amount, hasPdf FROM myInvoice ORDER BY issued DESC @@ -16,8 +16,9 @@ + icon="download" + tip="_Download PDF" + on-clicked="onDownloadClick"/>