From e7899c2f13648f33e2651bfd524fccc20951bb85 Mon Sep 17 00:00:00 2001 From: Robin Heinz Date: Mon, 16 Nov 2020 11:23:16 +0000 Subject: [PATCH] [FIX] point_of_sale: fiscal data module error. Allow to handle fiscal data module error and to not display the receipt in case the order is not validated Before, the user couldn't see the error and he could see a receipt that was not validated. Now we add a mechanism to handle all error that could occur with a fiscal data module. X-original-commit: 45646762467d589c3fb9c031841ae5f8137cf2cd --- .../static/src/js/Screens/PaymentScreen/PaymentScreen.js | 3 ++- addons/point_of_sale/static/src/js/custom_hooks.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js index 553309cdf1d..867a5d4241a 100644 --- a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js @@ -31,6 +31,7 @@ odoo.define('point_of_sale.PaymentScreen', function (require) { onChangeOrder(this._onPrevOrder, this._onNewOrder); useErrorHandlers(); this.payment_interface = null; + this.error = false; this.payment_methods_from_config = this.env.pos.payment_methods.filter(method => this.env.pos.config.payment_method_ids.includes(method.id)); } get currentOrder() { @@ -226,7 +227,7 @@ odoo.define('point_of_sale.PaymentScreen', function (require) { } } get nextScreen() { - return 'ReceiptScreen'; + return !this.error? 'ReceiptScreen' : 'ProductScreen'; } async _isOrderValid(isForceValidate) { if (this.currentOrder.get_orderlines().length === 0) { diff --git a/addons/point_of_sale/static/src/js/custom_hooks.js b/addons/point_of_sale/static/src/js/custom_hooks.js index bedad8fbbad..c1e87b24ecb 100644 --- a/addons/point_of_sale/static/src/js/custom_hooks.js +++ b/addons/point_of_sale/static/src/js/custom_hooks.js @@ -38,6 +38,14 @@ odoo.define('point_of_sale.custom_hooks', function (require) { error.data.debug || this.env._t('The server encountered an error while receiving your order.'), }); + } else if (error.code === 700) { + // Fiscal module errors + await this.showPopup('ErrorPopup', { + title: this.env._t('Fiscal data module error'), + body: + error.data.error.status || + this.env._t('The fiscal data module encountered an error while receiving your order.'), + }); } else { // ??? await this.showPopup('ErrorPopup', {