[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
This commit is contained in:
Joseph Caburnay
2022-07-05 00:50:52 +02:00
parent 424635bf1b
commit 5dca98315a
2 changed files with 9 additions and 2 deletions
@@ -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',
@@ -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', {