From 93deb095c819771080199c42c87db178ce9a2acd Mon Sep 17 00:00:00 2001 From: Antoine Prieels Date: Wed, 9 Oct 2019 11:54:11 +0000 Subject: [PATCH] [FIX] point_of_sale: Scrollbar on receipt print A scrollbar appeared every time a receipt was printed. To fix this, we put a height of 0 to the div that contains the receipt. html2canvas then had trouble computing the height of the background. There's a `height` option that can be given to the library but if the logo on the receipt was not loaded yet, the size we computed was wrong. We then compute the height only once the images have been loaded, in the `onparsed` method. We also remove a CSS class that wasn't used anymore. X-original-commit: 84418ae5bc1509c2c45323ecf6aed4ce4811f4d5 --- addons/point_of_sale/static/src/css/pos.css | 3 --- addons/point_of_sale/static/src/css/pos_receipts.css | 11 +++++------ addons/point_of_sale/static/src/js/printers.js | 6 +++++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 09e257d5f06..36ab2b77938 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -1546,9 +1546,6 @@ td { font-size: 13px !important; width: 266px !important; } - .pos .pos-receipts{ - display: none !important; - } .o_debug_manager { display: none !important; } diff --git a/addons/point_of_sale/static/src/css/pos_receipts.css b/addons/point_of_sale/static/src/css/pos_receipts.css index ad064c3d091..53731cc06eb 100644 --- a/addons/point_of_sale/static/src/css/pos_receipts.css +++ b/addons/point_of_sale/static/src/css/pos_receipts.css @@ -1,9 +1,13 @@ .pos-receipt-print { width: 512px; + height: 0; + overflow: hidden; + position: absolute; + left: 0; + top: 0; text-align: left; direction: ltr; font-size: 28px; - padding-bottom: 2em; color: #000000; } @@ -55,11 +59,6 @@ color: red; } -.pos-receipts { - height: 0; - overflow: hidden; -} - .pos-payment-terminal-receipt { text-align: center; font-size: 75%; diff --git a/addons/point_of_sale/static/src/js/printers.js b/addons/point_of_sale/static/src/js/printers.js index dc4072d7079..a18e0831427 100644 --- a/addons/point_of_sale/static/src/js/printers.js +++ b/addons/point_of_sale/static/src/js/printers.js @@ -48,7 +48,11 @@ var PrinterMixin = { var self = this; $('.pos-receipt-print').html(receipt); var promise = new Promise(function (resolve, reject) { - html2canvas($('.pos-receipt-print')[0], { + self.receipt = $('.pos-receipt-print>.pos-receipt'); + html2canvas(self.receipt[0], { + onparsed: function(queue) { + queue.stack.ctx.height = Math.ceil(self.receipt.outerHeight() + self.receipt.offset().top); + }, onrendered: function (canvas) { $('.pos-receipt-print').empty(); resolve(self.process_canvas(canvas));