diff --git a/addons/point_of_sale/static/src/js/Gui.js b/addons/point_of_sale/static/src/js/Gui.js index a4317f09f76..6be8f41014a 100644 --- a/addons/point_of_sale/static/src/js/Gui.js +++ b/addons/point_of_sale/static/src/js/Gui.js @@ -36,6 +36,7 @@ odoo.define('point_of_sale.Gui', function (require) { const configureGui = ({ component }) => { config.component = component; config.availableMethods = new Set([ + 'showScreen', 'showPopup', 'showTempScreen', 'playSound', diff --git a/addons/pos_sale/static/src/js/SetSaleOrderButton.js b/addons/pos_sale/static/src/js/SetSaleOrderButton.js index 3c7ad5792ef..2c7633a5599 100644 --- a/addons/pos_sale/static/src/js/SetSaleOrderButton.js +++ b/addons/pos_sale/static/src/js/SetSaleOrderButton.js @@ -6,6 +6,7 @@ odoo.define('pos_sale.SetSaleOrderButton', function(require) { const { useListener } = require("@web/core/utils/hooks"); const Registries = require('point_of_sale.Registries'); const { isConnectionError } = require('point_of_sale.utils'); + const { Gui } = require('point_of_sale.Gui'); class SetSaleOrderButton extends PosComponent { setup() { @@ -18,13 +19,18 @@ odoo.define('pos_sale.SetSaleOrderButton', function(require) { async onClick() { try { // ping the server, if no error, show the screen - await this.rpc({ + // Use rpc from services which resolves even when this + // component is destroyed (removed together with the popup). + await this.env.services.rpc({ model: 'sale.order', method: 'browse', args: [[]], kwargs: { context: this.env.session.user_context }, }); - this.showScreen('SaleOrderManagementScreen'); + // LegacyComponent doesn't work the same way as before. + // We need to use Gui here to show the screen. This will work + // because ui methods in Gui is bound to the root component. + Gui.showScreen('SaleOrderManagementScreen'); } catch (error) { if (isConnectionError(error)) { this.showPopup('ErrorPopup', {