From 4629a4fb0eacedb024562ef5542011d2e0b2c1f4 Mon Sep 17 00:00:00 2001 From: Gert Pellin Date: Wed, 21 Nov 2018 15:30:04 +0000 Subject: [PATCH] [FIX] point_of_sale: traceback on printing android Firefox for android gives atraceback when clicking the print receipt button. This traceback is caused becaus Firefox for Android does not support printing. This fix replaces the traceback by an explanation why it is not possible to print. Also backport for safari-fix closes odoo/odoo#28919 --- addons/point_of_sale/static/src/js/screens.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 8b1b001c340..7c1cb9559a6 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -1487,7 +1487,22 @@ var ReceiptScreenWidget = ScreenWidget.extend({ } }, print_web: function() { - window.print(); + if ($.browser.safari) { + document.execCommand('print', false, null); + } else { + try { + window.print(); + } catch(err) { + if (navigator.userAgent.toLowerCase().indexOf("android") > -1) { + this.gui.show_popup('error',{ + 'title':_t('Printing is not supported on some android browsers'), + 'body': _t('Printing is not supported on some android browsers due to no default printing protocol is available. It is possible to print your tickets by making use of an IoT Box.'), + }); + } else { + throw err; + } + } + } this.pos.get_order()._printed = true; }, print_xml: function() {