diff --git a/addons/l10n_fr_pos_cert/static/src/js/Popups/ClosePosPopup.js b/addons/l10n_fr_pos_cert/static/src/js/Popups/ClosePosPopup.js
index 88986c32598..2b6af668273 100644
--- a/addons/l10n_fr_pos_cert/static/src/js/Popups/ClosePosPopup.js
+++ b/addons/l10n_fr_pos_cert/static/src/js/Popups/ClosePosPopup.js
@@ -6,9 +6,9 @@ import { patch } from "@web/core/utils/patch";
patch(ClosePosPopup.prototype, "l10n_fr_pos_cert.ClosePosPopup", {
sessionIsOutdated() {
let isOutdated = false;
- if (this.env.pos.is_french_country() && this.env.pos.pos_session.start_at) {
+ if (this.pos.globalState.is_french_country() && this.pos.globalState.pos_session.start_at) {
const now = Date.now();
- const limitDate = new Date(this.env.pos.pos_session.start_at);
+ const limitDate = new Date(this.pos.globalState.pos_session.start_at);
limitDate.setDate(limitDate.getDate() + 1);
isOutdated = limitDate < now;
}
diff --git a/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js b/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js
index 302a2f2fdf1..250672d14b8 100644
--- a/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js
+++ b/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js
@@ -6,6 +6,7 @@ import { renderToString } from "@web/core/utils/render";
import { useAutofocus, useService } from "@web/core/utils/hooks";
import { parseFloat, InvalidNumberError } from "@web/views/fields/parsers";
import { useState } from "@odoo/owl";
+import { usePos } from "@point_of_sale/app/pos_hook";
import { AbstractAwaitablePopup } from "@point_of_sale/js/Popups/AbstractAwaitablePopup";
import { ErrorPopup } from "@point_of_sale/js/Popups/ErrorPopup";
@@ -18,6 +19,7 @@ export class CashMovePopup extends AbstractAwaitablePopup {
this.notification = useService("pos_notification");
this.popup = useService("popup");
this.orm = useService("orm");
+ this.pos = usePos();
this.hardwareProxy = useService("hardware_proxy");
this.state = useState({
/** @type {'in'|'out'} */
@@ -43,7 +45,7 @@ export class CashMovePopup extends AbstractAwaitablePopup {
this.state.errorMessage = this.env._t("Insert a positive amount");
return;
}
- const formattedAmount = this.env.pos.format_currency(amount);
+ const formattedAmount = this.pos.globalState.format_currency(amount);
if (!amount) {
this.notification.add(
sprintf(_t("Cash in/out of %s is ignored."), formattedAmount),
@@ -57,7 +59,7 @@ export class CashMovePopup extends AbstractAwaitablePopup {
const extras = { formattedAmount, translatedType };
const reason = this.state.reason.trim();
await this.orm.call("pos.session", "try_cash_in_out", [
- [this.env.pos.pos_session.id],
+ [this.pos.globalState.pos_session.id],
type,
amount,
reason,
@@ -71,8 +73,8 @@ export class CashMovePopup extends AbstractAwaitablePopup {
amount,
translatedType,
formattedAmount,
- cashier: this.env.pos.get_cashier(),
- company: this.env.pos.company,
+ cashier: this.pos.globalState.get_cashier(),
+ company: this.pos.globalState.company,
},
});
const printResult = await this.hardwareProxy.printer.print_receipt(renderedReceipt);
diff --git a/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.xml b/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.xml
index f0f2ec45226..01a95652291 100644
--- a/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.xml
+++ b/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.xml
@@ -14,11 +14,11 @@
-
-
+
+
-
+
diff --git a/addons/point_of_sale/static/src/app/popup/popup_service.js b/addons/point_of_sale/static/src/app/popup/popup_service.js
index 1708869e3f3..f87a0fc63fc 100644
--- a/addons/point_of_sale/static/src/app/popup/popup_service.js
+++ b/addons/point_of_sale/static/src/app/popup/popup_service.js
@@ -2,13 +2,9 @@
import { Component, reactive } from "@odoo/owl";
import { registry } from "@web/core/registry";
-import { usePos } from "@point_of_sale/app/pos_hook";
+
export class PopupContainer extends Component {
static template = "point_of_sale.PopupContainer";
- setup() {
- // FIXME POSREF: remove this when Chrome uses the new env
- this.__owl__.childEnv = usePos().legacyEnv;
- }
}
// FIXME POSREF: probably should use the main dialog service from web long term.
diff --git a/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js b/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js
index 354cdc7f6c2..72870bc51d0 100644
--- a/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js
@@ -2,6 +2,7 @@
import { AbstractAwaitablePopup } from "@point_of_sale/js/Popups/AbstractAwaitablePopup";
import { useService } from "@web/core/utils/hooks";
+import { usePos } from "@point_of_sale/app/pos_hook";
import { MoneyDetailsPopup } from "./MoneyDetailsPopup";
import { useState } from "@odoo/owl";
@@ -13,19 +14,20 @@ export class CashOpeningPopup extends AbstractAwaitablePopup {
super.setup();
this.manualInputCashCount = null;
this.moneyDetails = null;
+ this.pos = usePos();
this.state = useState({
notes: "",
- openingCash: this.env.pos.pos_session.cash_register_balance_start || 0,
+ openingCash: this.pos.globalState.pos_session.cash_register_balance_start || 0,
});
this.popup = useService("popup");
this.orm = useService("orm");
}
//@override
async confirm() {
- this.env.pos.pos_session.cash_register_balance_start = this.state.openingCash;
- this.env.pos.pos_session.state = "opened";
+ this.pos.globalState.pos_session.cash_register_balance_start = this.state.openingCash;
+ this.pos.globalState.pos_session.state = "opened";
this.orm.call("pos.session", "set_cashbox_pos", [
- this.env.pos.pos_session.id,
+ this.pos.globalState.pos_session.id,
this.state.openingCash,
this.state.notes,
]);
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 b05028d79ab..55f49d36b17 100644
--- a/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js
@@ -11,6 +11,7 @@ import { useState } from "@odoo/owl";
import { ConnectionLostError } from "@web/core/network/rpc_service";
import { identifyError } from "@point_of_sale/app/error_handlers/error_handlers";
import { _t } from "@web/core/l10n/translation";
+import { usePos } from "@point_of_sale/app/pos_hook";
export class ClosePosPopup extends AbstractAwaitablePopup {
static components = { SaleDetailsButton };
@@ -18,12 +19,13 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
setup() {
super.setup();
+ this.pos = usePos();
this.popup = useService("popup");
- this.pos = useService("pos");
this.orm = useService("orm");
this.hardwareProxy = useService("hardware_proxy");
+ this.legacyActionManager = useService("legacy_action_manager");
this.manualInputCashCount = false;
- this.cashControl = this.env.pos.config.cash_control;
+ this.cashControl = this.pos.globalState.config.cash_control;
this.closeSessionClicked = false;
this.moneyDetails = null;
Object.assign(this, this.props.info);
@@ -54,7 +56,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
"The maximum difference allowed is %s.\n\
Please contact your manager to accept the closing difference."
),
- this.env.pos.format_currency(this.amountAuthorizedDiff)
+ this.pos.globalState.format_currency(this.amountAuthorizedDiff)
),
confirmText: this.env._t("OK"),
});
@@ -77,7 +79,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
const { total, moneyDetailsNotes, moneyDetails } = payload;
this.state.payments[this.defaultCashDetails.id].counted = total;
this.state.payments[this.defaultCashDetails.id].difference =
- this.env.pos.round_decimals_currency(
+ this.pos.globalState.round_decimals_currency(
this.state.payments[[this.defaultCashDetails.id]].counted -
this.defaultCashDetails.amount
);
@@ -89,9 +91,9 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
}
}
async downloadSalesReport() {
- await this.env.legacyActionManager.do_action("point_of_sale.sale_details_report", {
+ await this.legacyActionManager.do_action("point_of_sale.sale_details_report", {
additional_context: {
- active_ids: [this.env.pos.pos_session.id],
+ active_ids: [this.pos.globalState.pos_session.id],
},
});
}
@@ -105,7 +107,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
} else {
expectedAmount = this.otherPaymentMethods.find((pm) => paymentId === pm.id).amount;
}
- this.state.payments[paymentId].difference = this.env.pos.round_decimals_currency(
+ this.state.payments[paymentId].difference = this.pos.globalState.round_decimals_currency(
this.state.payments[paymentId].counted - expectedAmount
);
}
@@ -129,12 +131,12 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
if (!this.closeSessionClicked) {
this.closeSessionClicked = true;
- if (this.env.pos.config.cashControl) {
+ if (this.pos.globalState.config.cashControl) {
const response = await this.orm.call(
"pos.session",
- "post_closing_cash_details"[this.env.pos.pos_session.id],
+ "post_closing_cash_details"[this.pos.globalState.pos_session.id],
{
- counted_cash: this.env.pos.config.cashControl
+ counted_cash: this.pos.globalState.config.cashControl
? this.state.payments[this.defaultCashDetails.id].counted
: 0,
}
@@ -147,7 +149,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
try {
await this.orm.call("pos.session", "update_closing_control_state_session", [
- this.env.pos.pos_session.id,
+ this.pos.globalState.pos_session.id,
this.state.notes,
]);
} catch (error) {
@@ -168,7 +170,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
.filter((pm) => pm.type == "bank")
.map((pm) => [pm.id, this.state.payments[pm.id].difference]);
const response = await this.orm.call("pos.session", "close_session_from_ui", [
- this.env.pos.pos_session.id,
+ this.pos.globalState.pos_session.id,
bankPaymentMethodDiffPairs,
]);
if (!response.successful) {
diff --git a/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js b/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js
index cd9c3f14bb7..a23dc6b977a 100644
--- a/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js
@@ -2,7 +2,7 @@
import { ErrorPopup } from "@point_of_sale/js/Popups/ErrorPopup";
import { _lt } from "@web/core/l10n/translation";
-import { useService } from "@web/core/utils/hooks";
+import { usePos } from "@point_of_sale/app/pos_hook";
// formerly ErrorTracebackPopupWidget
export class ErrorTracebackPopup extends ErrorPopup {
@@ -18,7 +18,7 @@ export class ErrorTracebackPopup extends ErrorPopup {
};
setup() {
- this.pos = useService("pos");
+ this.pos = usePos();
}
get tracebackUrl() {
@@ -30,7 +30,7 @@ export class ErrorTracebackPopup extends ErrorPopup {
return `${this.env._t("error")} ${moment().format("YYYY-MM-DD-HH-mm-ss")}.txt`;
}
emailTraceback() {
- const address = this.env.pos.company.email;
+ const address = this.pos.globalState.company.email;
const subject = this.env._t("IMPORTANT: Bug Report From Odoo Point Of Sale");
window.open(
"mailto:" +
diff --git a/addons/point_of_sale/static/src/js/Popups/MoneyDetailsPopup.js b/addons/point_of_sale/static/src/js/Popups/MoneyDetailsPopup.js
index e16be77251e..b1e37e2f655 100644
--- a/addons/point_of_sale/static/src/js/Popups/MoneyDetailsPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/MoneyDetailsPopup.js
@@ -3,6 +3,7 @@
import { AbstractAwaitablePopup } from "@point_of_sale/js/Popups/AbstractAwaitablePopup";
import { useState } from "@odoo/owl";
import { CurrencyAmount } from "../Misc/CurrencyAmount";
+import { usePos } from "@point_of_sale/app/pos_hook";
export class MoneyDetailsPopup extends AbstractAwaitablePopup {
static components = { CurrencyAmount };
@@ -10,11 +11,12 @@ export class MoneyDetailsPopup extends AbstractAwaitablePopup {
setup() {
super.setup();
- this.currency = this.env.pos.currency;
+ this.pos = usePos();
+ this.currency = this.pos.globalState.currency;
this.state = useState({
moneyDetails: this.props.moneyDetails
? { ...this.props.moneyDetails }
- : Object.fromEntries(this.env.pos.bills.map((bill) => [bill.value, 0])),
+ : Object.fromEntries(this.pos.globalState.bills.map((bill) => [bill.value, 0])),
total: this.props.total ? this.props.total : 0,
});
}
@@ -34,16 +36,16 @@ export class MoneyDetailsPopup extends AbstractAwaitablePopup {
(total, money) => total + money[0] * money[1],
0
);
- this.state.total = this.env.pos.round_decimals_currency(total);
+ this.state.total = this.pos.globalState.round_decimals_currency(total);
}
//@override
async getPayload() {
let moneyDetailsNotes = this.state.total ? "Money details: \n" : null;
- this.env.pos.bills.forEach((bill) => {
+ this.pos.globalState.bills.forEach((bill) => {
if (this.state.moneyDetails[bill.value]) {
moneyDetailsNotes += ` - ${
this.state.moneyDetails[bill.value]
- } x ${this.env.pos.format_currency(bill.value)}\n`;
+ } x ${this.pos.globalState.format_currency(bill.value)}\n`;
}
});
return {
diff --git a/addons/point_of_sale/static/src/js/Popups/NumberPopup.js b/addons/point_of_sale/static/src/js/Popups/NumberPopup.js
index 7ffdbe02bde..f098c21f95b 100644
--- a/addons/point_of_sale/static/src/js/Popups/NumberPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/NumberPopup.js
@@ -5,6 +5,7 @@ var _t = core._t;
import { AbstractAwaitablePopup } from "@point_of_sale/js/Popups/AbstractAwaitablePopup";
import { useService } from "@web/core/utils/hooks";
import { useState } from "@odoo/owl";
+import { localization } from "@web/core/l10n/localization";
export class NumberPopup extends AbstractAwaitablePopup {
static template = "NumberPopup";
@@ -45,7 +46,7 @@ export class NumberPopup extends AbstractAwaitablePopup {
});
}
get decimalSeparator() {
- return this.env._t.database.parameters.decimal_point;
+ return localization.decimalPoint;
}
get inputBuffer() {
if (this.state.buffer === null) {
diff --git a/addons/point_of_sale/static/src/js/Popups/ProductConfiguratorPopup.js b/addons/point_of_sale/static/src/js/Popups/ProductConfiguratorPopup.js
index 47f8f4dbd00..ca3e876ca61 100644
--- a/addons/point_of_sale/static/src/js/Popups/ProductConfiguratorPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ProductConfiguratorPopup.js
@@ -1,12 +1,13 @@
/** @odoo-module */
import { AbstractAwaitablePopup } from "@point_of_sale/js/Popups/AbstractAwaitablePopup";
import { Component, useRef, useState, useSubEnv } from "@odoo/owl";
+import { usePos } from "@point_of_sale/app/pos_hook";
export class BaseProductAttribute extends Component {
setup() {
super.setup();
+ this.pos = usePos();
this.env.attribute_components.push(this);
-
this.attribute = this.props.attribute;
this.values = this.attribute.values;
this.state = useState({
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 88c487c10c3..e5674a77141 100644
--- a/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js
@@ -1,6 +1,7 @@
/** @odoo-module */
import { AbstractAwaitablePopup } from "@point_of_sale/js/Popups/AbstractAwaitablePopup";
+import { usePos } from "@point_of_sale/app/pos_hook";
/**
* Props:
@@ -14,17 +15,18 @@ export class ProductInfoPopup extends AbstractAwaitablePopup {
setup() {
super.setup();
+ this.pos = usePos();
Object.assign(this, this.props.info);
}
searchProduct(productName) {
- this.env.pos.setSelectedCategoryId(0);
- this.env.pos.searchProductWord = productName;
+ this.pos.globalState.setSelectedCategoryId(0);
+ this.pos.globalState.searchProductWord = productName;
this.cancel();
}
_hasMarginsCostsAccessRights() {
const isAccessibleToEveryUser =
- this.env.pos.config.is_margins_costs_accessible_to_every_user;
- const isCashierManager = this.env.pos.get_cashier().role === "manager";
+ this.pos.globalState.config.is_margins_costs_accessible_to_every_user;
+ const isCashierManager = this.pos.globalState.get_cashier().role === "manager";
return isAccessibleToEveryUser || isCashierManager;
}
}
diff --git a/addons/point_of_sale/static/src/xml/Popups/ClosePosPopup.xml b/addons/point_of_sale/static/src/xml/Popups/ClosePosPopup.xml
index d4a66513acb..fcca0f7a265 100644
--- a/addons/point_of_sale/static/src/xml/Popups/ClosePosPopup.xml
+++ b/addons/point_of_sale/static/src/xml/Popups/ClosePosPopup.xml
@@ -7,7 +7,7 @@
Closing Session
Total orders:
-
+
@@ -25,20 +25,20 @@
|
- |
+ |
|
- |
+ |
| Opening |
- |
+ |
|
@@ -47,7 +47,7 @@
|
- |
+ |
|
@@ -56,17 +56,17 @@
Payments in
|
- |
+ |
|
- |
+ |
|
- |
+ |
diff --git a/addons/point_of_sale/static/src/xml/Popups/MoneyDetailsPopup.xml b/addons/point_of_sale/static/src/xml/Popups/MoneyDetailsPopup.xml
index 0e341217f06..8a8914b4a24 100644
--- a/addons/point_of_sale/static/src/xml/Popups/MoneyDetailsPopup.xml
+++ b/addons/point_of_sale/static/src/xml/Popups/MoneyDetailsPopup.xml
@@ -18,7 +18,7 @@
Total
-
+