[FIX] pos_epson_printer: more details on printer errors

Before this commit:
If the ePos printer is reachable but is
configured incorrectly (change of Device ID, etc.)
or have an issue (missing paper, etc.),
a generic error message will be given:
"Please check if the printer has enough paper
and is ready to print."
This is too generic considering the amount of issue
that can happen and the fact that the printer itself
does send to us a `code` which give good indication
on the origin of the issue.
The list of these codes can be seen at:
https://files.support.epson.com/pdf/pos/bulk/server_direct_print_um_en_revk.pdf#page=52

In version 14 this code was given in the error message.
But this feature was lost in the versions above

&

 Trying to print a receipt from the PoS with
 a wrongly configured ePoS printer will just pop
 the confirmation popup:
 'Do you want to print using the web printer?'
 Without giving any details regarding the errors
 causing the issue

After this commit:
A more precise error message is given:
 - Containing the printer error code
 - Giving recommendation on how to search
 online to solve the issue
 - On the specific case of the `Device ID`
 setting changed, give more details on the
 value to use

&

 The error pop-up with the error details
 is displayed first. Then the confirmation one

 opw-3188576
 opw-3071709

closes odoo/odoo#116020

X-original-commit: 1f753d31c925e479e8243a6427a24b3da99bfc31
Signed-off-by: Loan (LSE) <lse@odoo.com>
Signed-off-by: Loan (LSE) <lse@odoo.com>
Signed-off-by: Sens Loan (lse) <lse@odoo.com>
This commit is contained in:
Loan (LSE)
2023-03-21 19:54:34 +01:00
parent e3c0e04ac9
commit dbf12af2fa
4 changed files with 68 additions and 9 deletions
@@ -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?",
@@ -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();
@@ -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 ""
@@ -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")};
},
});