diff --git a/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js b/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js index 1980266cbca..b01e79024b2 100644 --- a/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js +++ b/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js @@ -25,6 +25,10 @@ export class AbstractReceiptScreen extends Component { if (printResult.successful) { return true; } else { + await this.popup.add(ErrorPopup, { + title: printResult.message.title, + body: printResult.message.body, + }); const { confirmed } = await this.popup.add(ConfirmPopup, { title: printResult.message.title, body: "Do you want to print using the web printer?", diff --git a/addons/point_of_sale/static/src/js/printers.js b/addons/point_of_sale/static/src/js/printers.js index 5205f37a0c2..9a8fee1bf61 100644 --- a/addons/point_of_sale/static/src/js/printers.js +++ b/addons/point_of_sale/static/src/js/printers.js @@ -77,7 +77,7 @@ export const PrinterMixin = { // IoT box can't find a printer. if (!sendPrintResult || sendPrintResult.result === false) { this.receipt_queue.length = 0; - return this.printResultGenerator.IoTResultError(); + return this.printResultGenerator.IoTResultError(sendPrintResult.printerErrorCode); } } return this.printResultGenerator.Successful(); diff --git a/addons/pos_epson_printer/i18n/pos_epson_printer.pot b/addons/pos_epson_printer/i18n/pos_epson_printer.pot index 8d5b5e49562..f6afec24908 100644 --- a/addons/pos_epson_printer/i18n/pos_epson_printer.pot +++ b/addons/pos_epson_printer/i18n/pos_epson_printer.pot @@ -26,6 +26,14 @@ msgstr "" msgid "Config Settings" msgstr "" +#. module: pos_epson_printer +#. openerp-web +#: code:addons/pos_epson_printer/static/src/js/printers.js:0 +#, python-format +msgid "" +"Check on the printer configuration for the 'Device ID' setting. It should be set to: " +msgstr "" + #. module: pos_epson_printer #. openerp-web #: code:addons/pos_epson_printer/static/src/js/printers.js:0 @@ -58,6 +66,13 @@ msgstr "" msgid "Local IP address of an Epson receipt printer." msgstr "" +#. module: pos_epson_printer +#. openerp-web +#: code:addons/pos_epson_printer/static/src/js/printers.js:0 +#, python-format +msgid "No paper was detected by the printer" +msgstr "" + #. module: pos_epson_printer #. openerp-web #: code:addons/pos_epson_printer/static/src/js/printers.js:0 @@ -95,6 +110,26 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:pos_epson_printer.pos_iot_config_view_form #: model_terms:ir.ui.view,arch_db:pos_epson_printer.res_config_settings_view_form msgid "" -"The Epson receipt printer will be used instead of the receipt printer " -"connected to the IoT Box." +"The Epson receipt printer will be used instead of the receipt printer connected to the IoT Box." +msgstr "" + +#. module: pos_epson_printer +#. openerp-web +#: code:addons/pos_epson_printer/static/src/js/printers.js:0 +#, python-format +msgid "The following error code was given by the printer:" +msgstr "" + +#. module: pos_epson_printer +#. openerp-web +#: code:addons/pos_epson_printer/static/src/js/printers.js:0 +#, python-format +msgid "The printer was successfully reached, but it wasn't able to print." +msgstr "" + +#. module: pos_epson_printer +#. openerp-web +#: code:addons/pos_epson_printer/static/src/js/printers.js:0 +#, python-format +msgid "To find more details on the error reason, please search online for:" msgstr "" diff --git a/addons/pos_epson_printer/static/src/js/printers.js b/addons/pos_epson_printer/static/src/js/printers.js index 43c86186874..c371adc411f 100644 --- a/addons/pos_epson_printer/static/src/js/printers.js +++ b/addons/pos_epson_printer/static/src/js/printers.js @@ -19,9 +19,9 @@ class EpsonPrintResultGenerator extends PrintResultGenerator { title: _t("Connection to the printer failed"), body: _t( "Please check if the printer is still connected. \n" + - "Some browsers don't allow HTTP calls from websites to devices in the network (for security reasons). " + - "If it is the case, you will need to follow Odoo's documentation for " + - "'Self-signed certificate for ePOS printers' and 'Secure connection (HTTPS)' to solve the issue" + "Some browsers don't allow HTTP calls from websites to devices in the network (for security reasons). " + + "If it is the case, you will need to follow Odoo's documentation for " + + "'Self-signed certificate for ePOS printers' and 'Secure connection (HTTPS)' to solve the issue" ), }, }); @@ -38,12 +38,31 @@ class EpsonPrintResultGenerator extends PrintResultGenerator { return printRes; } - IoTResultError() { + IoTResultError(printerErrorCode) { + let message = _t("The printer was successfully reached, but it wasn't able to print.") + '\n'; + if (printerErrorCode) { + message += '\n' + _t("The following error code was given by the printer:") + '\n' + printerErrorCode; + + const extra_messages = { + "DeviceNotFound": + _t("Check on the printer configuration for the 'Device ID' setting. " + + "It should be set to: ") + "\nlocal_printer", + "EPTR_REC_EMPTY": + _t("No paper was detected by the printer"), + }; + if (printerErrorCode in extra_messages) { + message += '\n' + extra_messages[printerErrorCode]; + } + message += '\n' + _t("To find more details on the error reason, please search online for:") + '\n' + + " Epson Server Direct Print " + printerErrorCode; + } else { + message += _t("Please check if the printer has enough paper and is ready to print."); + } return new PrintResult({ successful: false, message: { title: _t("Printing failed"), - body: _t("Please check if the printer has enough paper and is ready to print."), + body: message, }, }); } @@ -164,6 +183,7 @@ export const EpsonPrinter = core.Class.extend(PrinterMixin, { method: "POST", data: img, }); - return $(res).find("response").attr("success") === "true"; + const response = $(res).find("response"); + return {"result": response.attr("success") === "true", "printerErrorCode": response.attr("code")}; }, });