[REF] point_of_sale: define formatProductQty in the contextual_utils_service

closes odoo/odoo#120317

Related: odoo/enterprise#40608
Signed-off-by: Samuel Degueldre <sad@odoo.com>
This commit is contained in:
Joseph Caburnay
2023-05-08 15:18:31 +02:00
parent 0589e3e734
commit 17882e3262
3 changed files with 10 additions and 10 deletions
@@ -1,6 +1,6 @@
/** @odoo-module */
import { formatMonetary } from "@web/views/fields/formatters";
import { formatMonetary, formatFloat } from "@web/views/fields/formatters";
import { roundDecimals } from "@web/core/utils/numbers";
import { registry } from "@web/core/registry";
@@ -12,6 +12,11 @@ export const contextualUtilsService = {
dependencies: ["pos"],
start(env, { pos }) {
const currency = pos.globalState.currency;
const productUoMDecimals = pos.globalState.dp["Product Unit of Measure"];
const formatProductQty = (qty) => {
return formatFloat(qty, { digits: [true, productUoMDecimals] });
};
const formatCurrency = (value, hasSymbol = true) => {
return formatMonetary(value, {
@@ -27,6 +32,7 @@ export const contextualUtilsService = {
env.utils = {
formatCurrency,
roundCurrency,
formatProductQty,
};
},
};
@@ -57,7 +57,7 @@ export class OrderlineDetails extends Component {
return !this.env.pos.isProductQtyZero(this.props.line.refunded_qty);
}
getFormattedRefundedQty() {
return this.env.pos.formatProductQty(this.props.line.refunded_qty);
return this.env.utils.formatProductQty(this.props.line.refunded_qty);
}
hasToRefundQty() {
const toRefundDetail = this.getToRefundDetail();
@@ -65,7 +65,7 @@ export class OrderlineDetails extends Component {
}
getFormattedToRefundQty() {
const toRefundDetail = this.getToRefundDetail();
return this.env.pos.formatProductQty(toRefundDetail && toRefundDetail.qty);
return this.env.utils.formatProductQty(toRefundDetail && toRefundDetail.qty);
}
getRefundingMessage() {
return sprintf(this.env._t("Refunding %s in "), this.getFormattedToRefundQty());
+1 -7
View File
@@ -1491,12 +1491,6 @@ export class PosGlobalState extends PosModel {
return floatIsZero(qty, this.dp["Product Unit of Measure"]);
}
formatProductQty(qty) {
return formatFloat(qty, {
digits: [true, this.dp["Product Unit of Measure"]],
});
}
disallowLineQuantityChange() {
return false;
}
@@ -2019,7 +2013,7 @@ export class Orderline extends PosModel {
_t(
"The requested quantity to be refunded is higher than the refundable quantity of %s."
),
this.pos.formatProductQty(maxQtyToRefund)
this.pos.env.utils.formatProductQty(maxQtyToRefund)
),
});
return false;