Skip to content

Commit

Permalink
[FIX] canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
felipezago committed Jun 8, 2023
1 parent a40b51f commit 0eb9385
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
26 changes: 26 additions & 0 deletions l10n_br_pos_cfe/static/src/js/printers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (C) 2016-Today KMEE (https://kmee.com.br)
@author: Felipe Zago <[email protected]>
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;
});
4 changes: 4 additions & 0 deletions l10n_br_pos_cfe/views/pos_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
<script
src="/l10n_br_pos_cfe/static/src/js/ReceiptScreen/ReceiptScreen.js"
type="text/javascript"
/>
<script
src="/l10n_br_pos_cfe/static/src/js/printers.js"
type="text/javascript"
/>
</xpath>

Expand Down

0 comments on commit 0eb9385

Please sign in to comment.