diff --git a/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml b/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml
index 688bcbcd58f..d35b22410f2 100644
--- a/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml
+++ b/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml
@@ -6,7 +6,7 @@
-
+
Back
diff --git a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderFetcher.js b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderFetcher.js
index c99b9c23b7e..ec7d0f9ab5e 100644
--- a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderFetcher.js
+++ b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderFetcher.js
@@ -3,7 +3,7 @@
import { Gui } from "@point_of_sale/js/Gui";
const { EventBus } = owl;
-
+// FIXME POSREF: should probably be a service instead of a singleton.
class SaleOrderFetcher extends EventBus {
constructor() {
super();
diff --git a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js
index d58be411e26..3157508d0b4 100644
--- a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js
+++ b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js
@@ -2,10 +2,9 @@
import { sprintf } from "web.utils";
import { parse } from "web.field_utils";
-import { useListener } from "@web/core/utils/hooks";
+import { useListener, useService } from "@web/core/utils/hooks";
import { registry } from "@web/core/registry";
import { ControlButtonsMixin } from "@point_of_sale/js/ControlButtonsMixin";
-import { numberBuffer } from "@point_of_sale/js/Misc/NumberBuffer";
import { saleOrderFetcher } from "@pos_sale/js/OrderManagementScreen/SaleOrderFetcher";
import { IndependentToOrderScreen } from "@point_of_sale/js/Misc/IndependentToOrderScreen";
import { orderManagement } from "@point_of_sale/js/PosContext";
@@ -24,10 +23,11 @@ const { onMounted, onWillUnmount, useState } = owl;
export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentToOrderScreen) {
static components = { SaleOrderList, SaleOrderManagementControlPanel };
static template = "SaleOrderManagementScreen";
- static hideOrderSelector = true;
setup() {
super.setup();
+ this.popup = useService("popup");
+ this.numberBuffer = useService("number_buffer");
useListener("close-screen", this.close);
useListener("click-sale-order", this._onClickSaleOrder);
useListener("next-page", this._onNextPage);
@@ -72,7 +72,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
async _setNumpadMode(event) {
const { mode } = event.detail;
this.numpadMode = mode;
- numberBuffer.reset();
+ this.numberBuffer.reset();
}
_onNextPage() {
saleOrderFetcher.nextPage();
@@ -87,7 +87,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
}
async _onClickSaleOrder(event) {
const clickedOrder = event.detail;
- const { confirmed, payload: selectedOption } = await this.showPopup(SelectionPopup, {
+ const { confirmed, payload: selectedOption } = await this.popup.add(SelectionPopup, {
title: this.env._t("What do you want to do?"),
list: [
{ id: "0", label: this.env._t("Apply a down payment"), item: false },
@@ -116,7 +116,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
this.env._t("There was a problem in loading the %s customer."),
sale_order.partner_id[1]
);
- await this.showPopup(ErrorPopup, { title, body });
+ await this.popup.add(ErrorPopup, { title, body });
}
currentPOSOrder.set_partner(
this.env.pos.db.get_partner_by_id(sale_order.partner_id[0])
@@ -146,7 +146,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
.filter((line) => !this.env.pos.db.get_product_by_id(line.product_id[0]))
.map((line) => line.product_id[0]);
if (product_to_add_in_pos.length) {
- const { confirmed } = await this.showPopup(ConfirmPopup, {
+ const { confirmed } = await this.popup.add(ConfirmPopup, {
title: this.env._t("Products not available in POS"),
body: this.env._t(
"Some of the products in your Sale Order are not available in POS, do you want to import them?"
@@ -202,7 +202,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
// Ask once when `useLoadedLots` is undefined, then reuse it's value on the succeeding lines.
const { confirmed } =
useLoadedLots === undefined
- ? await this.showPopup(ConfirmPopup, {
+ ? await this.popup.add(ConfirmPopup, {
title: this.env._t("SN/Lots Loading"),
body: this.env._t(
"Do you want to load the SN/Lots linked to the Sales Order?"
@@ -244,7 +244,9 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
this.env.pos.config.down_payment_product_id[0]
);
if (!down_payment_product) {
- await this.env.pos._addProducts([this.env.pos.config.down_payment_product_id[0]]);
+ await this.env.pos._addProducts([
+ this.env.pos.config.down_payment_product_id[0],
+ ]);
down_payment_product = this.env.pos.db.get_product_by_id(
this.env.pos.config.down_payment_product_id[0]
);
@@ -260,7 +262,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
down_payment = sale_order.amount_total;
}
- const { confirmed, payload } = await this.showPopup(NumberPopup, {
+ const { confirmed, payload } = await this.popup.add(NumberPopup, {
title: sprintf(
this.env._t("Percentage of %s"),
this.env.pos.format_currency(sale_order.amount_total)
@@ -291,7 +293,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
"It seems that you didn't configure a down payment product in your point of sale.\
You can go to your point of sale configuration to choose one."
);
- await this.showPopup(ErrorPopup, { title, body });
+ await this.popup.add(ErrorPopup, { title, body });
}
}
diff --git a/addons/pos_sale/static/src/js/SetSaleOrderButton.js b/addons/pos_sale/static/src/js/SetSaleOrderButton.js
index 5b73ee8a727..f86ff3e7dc0 100644
--- a/addons/pos_sale/static/src/js/SetSaleOrderButton.js
+++ b/addons/pos_sale/static/src/js/SetSaleOrderButton.js
@@ -3,13 +3,14 @@
import { PosComponent } from "@point_of_sale/js/PosComponent";
import { ProductScreen } from "@point_of_sale/js/Screens/ProductScreen/ProductScreen";
import { useListener } from "@web/core/utils/hooks";
-import { Gui } from "@point_of_sale/js/Gui";
+import { usePos } from "@point_of_sale/app/pos_hook";
export class SetSaleOrderButton extends PosComponent {
static template = "SetSaleOrderButton";
setup() {
super.setup();
+ this.pos = usePos();
useListener("click", this.onClick);
}
get currentOrder() {
@@ -25,13 +26,10 @@ export class SetSaleOrderButton extends PosComponent {
args: [[]],
kwargs: { context: this.env.session.user_context },
});
- // 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.
const screen = this.env.isMobile
? "MobileSaleOrderManagementScreen"
: "SaleOrderManagementScreen";
- Gui.showScreen(screen);
+ this.pos.showScreen(screen);
}
}
diff --git a/addons/pos_sale_product_configurator/static/src/js/models.js b/addons/pos_sale_product_configurator/static/src/js/models.js
index c48a3b2af28..0474e30ab0e 100644
--- a/addons/pos_sale_product_configurator/static/src/js/models.js
+++ b/addons/pos_sale_product_configurator/static/src/js/models.js
@@ -1,6 +1,5 @@
/** @odoo-module */
-import { Gui } from "@point_of_sale/js/Gui";
import { Order } from "@point_of_sale/js/models";
import { patch } from "@web/core/utils/patch";
@@ -21,7 +20,7 @@ patch(Order.prototype, "pos_sale_product_configurator.Order", {
if (isProductLoaded) {
const quantity = this.get_selected_orderline().get_quantity();
const info = await this.pos.getProductInfo(product, quantity);
- Gui.showPopup(ProductInfoPopup, { info: info, product: product });
+ this.pos.env.services.popup.add(ProductInfoPopup, { info: info, product: product });
}
}
},
diff --git a/addons/pos_six/static/src/js/payment_six.js b/addons/pos_six/static/src/js/payment_six.js
index 7e0e73dc8f2..855fdef930b 100644
--- a/addons/pos_six/static/src/js/payment_six.js
+++ b/addons/pos_six/static/src/js/payment_six.js
@@ -1,7 +1,6 @@
/** @odoo-module */
/* global timapi */
-import { Gui } from "@point_of_sale/js/Gui";
import core from "web.core";
import { PaymentInterface } from "@point_of_sale/js/payment";
import { ErrorPopup } from "@point_of_sale/js/Popups/ErrorPopup";
@@ -119,7 +118,7 @@ export const PaymentSix = PaymentInterface.extend({
if (event.exception) {
if (event.exception.resultCode !== timapi.constants.ResultCode.apiCancelEcr) {
- Gui.showPopup(ErrorPopup, {
+ this.pos.env.services.popup.add(ErrorPopup, {
title: _t("Transaction was not processed correctly"),
body: event.exception.errorText,
});
@@ -142,7 +141,7 @@ export const PaymentSix = PaymentInterface.extend({
_onBalanceComplete: function (event, data) {
if (event.exception) {
- Gui.showPopup(ErrorPopup, {
+ this.pos.env.services.popup.add(ErrorPopup, {
title: _t("Balance Failed"),
body: _t("The balance operation failed."),
});
diff --git a/addons/pos_stripe/static/src/js/payment_stripe.js b/addons/pos_stripe/static/src/js/payment_stripe.js
index e01c0dedf09..30e585024e7 100644
--- a/addons/pos_stripe/static/src/js/payment_stripe.js
+++ b/addons/pos_stripe/static/src/js/payment_stripe.js
@@ -4,7 +4,6 @@
import core from "web.core";
import rpc from "web.rpc";
import { PaymentInterface } from "@point_of_sale/js/payment";
-import { Gui } from "@point_of_sale/js/Gui";
import { ErrorPopup } from "@point_of_sale/js/Popups/ErrorPopup";
const _t = core._t;
@@ -142,8 +141,10 @@ export const PaymentStripe = PaymentInterface.extend({
captureAfterPayment: async function (processPayment, line) {
const capturePayment = await this.capturePayment(processPayment.paymentIntent.id);
- if (capturePayment.charges)
- {line.card_type = capturePayment.charges.data[0].payment_method_details.card_present.brand;}
+ if (capturePayment.charges) {
+ line.card_type =
+ capturePayment.charges.data[0].payment_method_details.card_present.brand;
+ }
line.transaction_id = capturePayment.id;
},
@@ -240,7 +241,7 @@ export const PaymentStripe = PaymentInterface.extend({
if (!title) {
title = _t("Stripe Error");
}
- Gui.showPopup(ErrorPopup, {
+ this.pos.env.services.popup.add(ErrorPopup, {
title: title,
body: msg,
});