[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
This commit is contained in:
Robin Heinz
2021-07-12 07:49:00 +00:00
committed by Pierre Masereel
parent c8ff9d7c46
commit e7899c2f13
2 changed files with 10 additions and 1 deletions
@@ -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) {
@@ -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', {