From 5dca98315a2cc52d348c167e954651d0e77280b1 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Mon, 4 Jul 2022 12:13:03 +0000 Subject: [PATCH] [FIX] pos_sale: properly show sale order screen When in mobile view, the sale order management screen don't show when clicking the Quotations button. This change fixes this problem. Check the comments in the changes for more details. X-original-commit: 4ac8c363213dec747a7ca1bf5f2b22c6e2c6abf2 Part-of: odoo/odoo#95282 --- addons/point_of_sale/static/src/js/Gui.js | 1 + addons/pos_sale/static/src/js/SetSaleOrderButton.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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', {