diff --git a/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js b/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js index efaf7ee7e7d..377d30f8e7f 100644 --- a/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js +++ b/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js @@ -6,7 +6,7 @@ odoo.define('point_of_sale.ClosePosPopup', function(require) { const { identifyError } = require('point_of_sale.utils'); const { ConnectionLostError, ConnectionAbortedError} = require('@web/core/network/rpc_service') - const { onWillStart, onMounted, useState } = owl; + const { onWillStart, useState } = owl; /** * This popup needs to be self-dependent because it needs to be called from different place. @@ -22,7 +22,6 @@ odoo.define('point_of_sale.ClosePosPopup', function(require) { displayMoneyDetailsPopup: false, }); onWillStart(this.onWillStart); - onMounted(this.onMounted); } async onWillStart() { try { @@ -54,22 +53,14 @@ odoo.define('point_of_sale.ClosePosPopup', function(require) { } Object.assign(this.state, state); } catch (error) { - this.error = error; - } - } - /* - * Since this popup need to be self dependent, in case of an error, the popup need to be closed on its own. - */ - onMounted() { - if (this.error) { this.cancel(); - if (identifyError(this.error) instanceof ConnectionLostError) { + if (identifyError(error) instanceof ConnectionLostError) { this.showPopup('ErrorPopup', { title: this.env._t('Network Error'), body: this.env._t('Please check your internet connection and try again.'), }); } else { - throw this.error; + throw error; } } } diff --git a/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js b/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js index b29a9531b05..a066cc7db11 100644 --- a/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js +++ b/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js @@ -3,6 +3,7 @@ odoo.define('point_of_sale.ProductInfoPopup', function(require) { const AbstractAwaitablePopup = require('point_of_sale.AbstractAwaitablePopup'); const Registries = require('point_of_sale.Registries'); + const { identifyError } = require('point_of_sale.utils'); const { ConnectionLostError } = require('@web/core/network/rpc_service') /** @@ -17,7 +18,6 @@ odoo.define('point_of_sale.ProductInfoPopup', function(require) { setup() { super.setup(); owl.onWillStart(this.onWillStart); - owl.onMounted(this.onMounted); } async onWillStart() { const order = this.env.pos.get_order(); @@ -48,22 +48,14 @@ odoo.define('point_of_sale.ProductInfoPopup', function(require) { this.orderMarginCurrency = this.env.pos.format_currency(orderMargin); this.orderMarginPercent = orderPriceWithoutTax ? Math.round(orderMargin/orderPriceWithoutTax * 10000) / 100 : 0; } catch (error) { - this.error = error; - } - } - /* - * Since this popup need to be self dependent, in case of an error, the popup need to be closed on its own. - */ - onMounted() { - if (this.error) { this.cancel(); - if (this.error.message instanceof ConnectionLostError) { + if (identifyError(error) instanceof ConnectionLostError) { this.showPopup('ErrorPopup', { title: this.env._t('Network Error'), body: this.env._t('Cannot access product information screen if offline.'), }); } else { - throw this.error; + throw error; } } }