Skip to content

Commit

Permalink
[FIX] point_of_sale: traceback on printing android
Browse files Browse the repository at this point in the history
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#28919
  • Loading branch information
Gert Pellin committed Nov 21, 2018
1 parent 2643e85 commit 4629a4f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion addons/point_of_sale/static/src/js/screens.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4629a4f

Please sign in to comment.