diff --git a/l10n_br_pos_cfe/static/src/js/ReceiptScreen/OrderFooterReceipt.js b/l10n_br_pos_cfe/static/src/js/ReceiptScreen/OrderFooterReceipt.js index 1cae1041f534..f46a09f16b86 100644 --- a/l10n_br_pos_cfe/static/src/js/ReceiptScreen/OrderFooterReceipt.js +++ b/l10n_br_pos_cfe/static/src/js/ReceiptScreen/OrderFooterReceipt.js @@ -39,15 +39,17 @@ odoo.define("l10n_br_pos_cfe.OrderFooterReceipt", function (require) { async _generateQRCode() { const qrCode = document.getElementById("footer__qrcode"); - this.observeElement(qrCode, this.dispatchEventAfterQrCodeDisplayed); + //this.observeElement(qrCode, this.dispatchEventAfterQrCodeDisplayed); // eslint-disable-next-line - return await new QRCode(document.getElementById("footer__qrcode"), { + await new QRCode(qrCode, { text: this.getTextForQRCode(), // eslint-disable-next-line correctLevel: QRCode.CorrectLevel.L, useSVG: true }); + + window.dispatchEvent(this.footerMountedEvent); } getFormattedDocumentKey() { @@ -90,15 +92,17 @@ odoo.define("l10n_br_pos_cfe.OrderFooterReceipt", function (require) { async _generateQRCodeCancel() { const qrCodeCancel = document.getElementById("footer__qrcode-cancel"); - this.observeElement(qrCodeCancel, this.dispatchEventAfterQrCodeDisplayed); + //this.observeElement(qrCodeCancel, this.dispatchEventAfterQrCodeDisplayed); // eslint-disable-next-line - return await new QRCode(qrCodeCancel, { + await new QRCode(qrCodeCancel, { text: this.getTextForQRCodeCancel(), // eslint-disable-next-line correctLevel: QRCode.CorrectLevel.L, useSVG: true }); + + window.dispatchEvent(this.footerMountedEvent); } getTextForQRCodeCancel() { diff --git a/l10n_br_pos_cfe/static/src/js/printers.js b/l10n_br_pos_cfe/static/src/js/printers.js new file mode 100644 index 000000000000..aeab4749be76 --- /dev/null +++ b/l10n_br_pos_cfe/static/src/js/printers.js @@ -0,0 +1,26 @@ +/* +Copyright (C) 2016-Today KMEE (https://kmee.com.br) +@author: Felipe Zago +License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +*/ +odoo.define("l10n_br_pos_cfe.Printer", function (require) { + "use strict"; + + var Printer = require("point_of_sale.Printer").Printer; + + Printer = Printer.include({ + htmlToImg: function (receipt) { + const self = this; + $('.pos-receipt-print').html(receipt); + return new Promise(function (resolve, reject) { + self.receipt = $('.pos-receipt-print>.pos-receipt'); + html2canvas(self.receipt[0]).then(canvas => { + $('.pos-receipt-print').empty(); + resolve(self.process_canvas(canvas)); + }); + }); + }, + }); + + return Printer; +}); diff --git a/l10n_br_pos_cfe/views/pos_template.xml b/l10n_br_pos_cfe/views/pos_template.xml index de8d10a185d6..c9a4c507acf9 100644 --- a/l10n_br_pos_cfe/views/pos_template.xml +++ b/l10n_br_pos_cfe/views/pos_template.xml @@ -57,6 +57,10 @@