From a0639cd1524f7b1589b5acd0945030cd74daa4a0 Mon Sep 17 00:00:00 2001 From: rhe-odoo Date: Thu, 9 Jun 2022 12:01:10 +0000 Subject: [PATCH] [IMP] point_of_sale: error handler belgian blackbox This commit aims to handle the belgian blackbox error properly just as the sweden blackbox do. Add an error code of 701 to handle the error messages. closes odoo/odoo#104233 Part-of: odoo/odoo#96583 X-original-commit: 7d1e52bcd11a1c20a6c6829c56d3fabe5b0f0fef Signed-off-by: Masereel Pierre --- .../src/js/Screens/PaymentScreen/PaymentScreen.js | 4 +--- addons/point_of_sale/static/src/js/custom_hooks.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) 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 c9dea799140..efad114c1bf 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 @@ -211,9 +211,7 @@ odoo.define('point_of_sale.PaymentScreen', function (require) { } } } catch (error) { - hasError = true; - - if (error.code == 700) + if (error.code == 700 || error.code == 701) this.error = true; if ('code' in error) { 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 b2131f398cd..180cbcdf177 100644 --- a/addons/point_of_sale/static/src/js/custom_hooks.js +++ b/addons/point_of_sale/static/src/js/custom_hooks.js @@ -38,13 +38,24 @@ odoo.define('point_of_sale.custom_hooks', function (require) { this.env._t('The server encountered an error while receiving your order.'), }); } else if (error.code === 700) { - // Fiscal module errors + // Sweden 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 if (error.code === 701) { + // Belgian Fiscal module errors + let bodyMessage = ""; + if(error.error.errorCode) + bodyMessage = "'" + error.error.errorCode + "': " + error.error.errorMessage; + else + bodyMessage = "Fiscal data module is not on."; + await this.showPopup('ErrorPopup', { + title: this.env._t('Fiscal data module error'), + body: bodyMessage + }); } else { // ??? await this.showPopup('ErrorPopup', {