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 077640e2c106..8396ab188dca 100644 --- a/l10n_br_pos_cfe/static/src/js/ReceiptScreen/OrderFooterReceipt.js +++ b/l10n_br_pos_cfe/static/src/js/ReceiptScreen/OrderFooterReceipt.js @@ -39,27 +39,16 @@ odoo.define("l10n_br_pos_cfe.OrderFooterReceipt", function (require) { async _generateQRCode() { const qrCode = document.getElementById("footer__qrcode"); - new MutationObserver(this.observerCallback.bind(this)).observe(qrCode, { - attributes: true, - subtree: true, - attributeFilter: ["style"] - }); - - const start = Date.now(); + this.observeElement(qrCode, this.dispatchEventAfterQrCodeDisplayed); // eslint-disable-next-line - await new QRCode(document.getElementById("footer__qrcode"), { + return await new QRCode(document.getElementById("footer__qrcode"), { text: this.getTextForQRCode(), width: 275, height: 275, - colorDark: "#000000", - colorLight: "#ffffff", // eslint-disable-next-line correctLevel: QRCode.CorrectLevel.L, }); - const end = Date.now(); - - console.log(`Gerar QR Code - Tempo de Execução: ${end - start} ms`); } getFormattedDocumentKey() { @@ -102,11 +91,7 @@ odoo.define("l10n_br_pos_cfe.OrderFooterReceipt", function (require) { async _generateQRCodeCancel() { const qrCodeCancel = document.getElementById("footer__qrcode-cancel"); - new MutationObserver(this.observerCallback.bind(this)).observe(qrCodeCancel, { - attributes: true, - subtree: true, - attributeFilter: ["style"] - }); + this.observeElement(qrCodeCancel, this.dispatchEventAfterQrCodeDisplayed); // eslint-disable-next-line return await new QRCode(qrCodeCancel, { @@ -143,11 +128,20 @@ odoo.define("l10n_br_pos_cfe.OrderFooterReceipt", function (require) { ); } - observerCallback(mutationList, observer) { + observeElement(element, callback) { + return new MutationObserver(callback.bind(this)).observe(element, { + attributes: true, + subtree: true, + attributeFilter: ["style"] + }); + } + + dispatchEventAfterQrCodeDisplayed(mutationList, observer) { const self = this; _.each(mutationList, (mutation) => { const currEl = mutation.target; - if (mutation.type == "attributes" && + if ( + mutation.type == "attributes" && currEl.tagName === "IMG" && currEl.style.display === "block" ) { diff --git a/l10n_br_pos_cfe/static/src/js/ReceiptScreen/ReceiptScreen.js b/l10n_br_pos_cfe/static/src/js/ReceiptScreen/ReceiptScreen.js index 55ba9088e998..7f419536fdc3 100644 --- a/l10n_br_pos_cfe/static/src/js/ReceiptScreen/ReceiptScreen.js +++ b/l10n_br_pos_cfe/static/src/js/ReceiptScreen/ReceiptScreen.js @@ -42,7 +42,9 @@ odoo.define("l10n_br_pos_cfe.ReceiptScreen", function (require) { } async _printReceipt() { - console.log("🚀 ~ file: ReceiptScreen.js:33 ~ extends ~ _printReceipt ~ this.orderReceipt.el.outerHTML: ", this.orderReceipt.el.outerHTML) + console.log("🚀 ~ file: ReceiptScreen.js:45 ~ extends ~ _printReceipt ~ this.orderReceipt.el.outerHTML: ", this.orderReceipt.el.outerHTML) + console.log("🚀 ~ file: ReceiptScreen.js:46 ~ extends ~ _printReceipt ~ receipt jquery: ", $(".pos-receipt").outerHTML); + console.log("🚀 ~ file: ReceiptScreen.js:47 ~ extends ~ _printReceipt ~ user agent: ", window.navigator.userAgent); return await ReceiptScreen.prototype._printReceipt.call(this); } }; diff --git a/l10n_br_pos_cfe/static/src/js/fiscal_cfe.js b/l10n_br_pos_cfe/static/src/js/fiscal_cfe.js index 71b34c099213..afa0696bfcf1 100644 --- a/l10n_br_pos_cfe/static/src/js/fiscal_cfe.js +++ b/l10n_br_pos_cfe/static/src/js/fiscal_cfe.js @@ -237,15 +237,9 @@ odoo.define("l10n_br_pos_cfe.FiscalDocumentCFe", function (require) { }, send_order_job: function (order_json) { - - const start = Date.now(); - const res = this.connection.rpc("/hw_proxy/enviar_cfe_sat", { + return this.connection.rpc("/hw_proxy/enviar_cfe_sat", { json: order_json, }); - const end = Date.now(); - console.log(`Enviar Cfe Sat - Tempo de Execução: ${end - start} ms`); - - return res }, cancel_order_job: function (order_json) {