[REF] point_of_sale: remove MobileOrderWidget
It's a very short component with no oevrrides that contains almost no logic and whose template is ~10 lines of code. It has been inlined into the ProductScreen. Part-of: odoo/odoo#122035
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
import { usePos } from "@point_of_sale/app/pos_hook";
|
||||
|
||||
export class MobileOrderWidget extends Component {
|
||||
static template = "MobileOrderWidget";
|
||||
|
||||
setup() {
|
||||
super.setup(...arguments);
|
||||
this.pos = usePos();
|
||||
}
|
||||
get order() {
|
||||
return this.pos.globalState.get_order();
|
||||
}
|
||||
get total() {
|
||||
const _total = this.order ? this.order.get_total_with_tax() : 0;
|
||||
return this.env.utils.formatCurrency(_total);
|
||||
}
|
||||
get items_number() {
|
||||
return this.order
|
||||
? this.order.orderlines.reduce((items_number, line) => items_number + line.quantity, 0)
|
||||
: 0;
|
||||
}
|
||||
clickPay() {
|
||||
const order = this.pos.globalState.get_order();
|
||||
|
||||
if (order.orderlines.length) {
|
||||
order.pay();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,6 @@ export class ActionpadWidget extends Component {
|
||||
get isLongName() {
|
||||
return this.props.partner && this.props.partner.name.length > 10;
|
||||
}
|
||||
|
||||
clickPay() {
|
||||
const order = this.pos.globalState.get_order();
|
||||
if (order.orderlines.length) {
|
||||
order.pay();
|
||||
}
|
||||
}
|
||||
|
||||
get highlightPay() {
|
||||
return this.pos.globalState.get_order()?.orderlines?.length;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,8 @@ import { ConnectionLostError } from "@web/core/network/rpc_service";
|
||||
|
||||
import { usePos } from "@point_of_sale/app/pos_hook";
|
||||
import { Component, onMounted, useState } from "@odoo/owl";
|
||||
import { ConfirmPopup } from "@point_of_sale/js/Popups/ConfirmPopup";
|
||||
import { ErrorBarcodePopup } from "@point_of_sale/js/Popups/ErrorBarcodePopup";
|
||||
|
||||
import { MobileOrderWidget } from "../../Misc/MobileOrderWidget";
|
||||
import { NumpadWidget } from "./NumpadWidget";
|
||||
import { OrderWidget } from "./OrderWidget";
|
||||
import { ProductsWidget } from "./ProductsWidget";
|
||||
@@ -27,7 +25,6 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
|
||||
static template = "ProductScreen";
|
||||
static components = {
|
||||
ActionpadWidget,
|
||||
MobileOrderWidget,
|
||||
NumpadWidget,
|
||||
OrderWidget,
|
||||
ProductsWidget,
|
||||
@@ -79,6 +76,12 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
|
||||
get currentOrder() {
|
||||
return this.pos.globalState.get_order();
|
||||
}
|
||||
get total() {
|
||||
return this.env.utils.formatCurrency(this.currentOrder?.get_total_with_tax() ?? 0);
|
||||
}
|
||||
get items() {
|
||||
return this.currentOrder.orderlines?.reduce((items, line) => items + line.quantity, 0) ?? 0;
|
||||
}
|
||||
async updateSelectedOrderline({ buffer, key }) {
|
||||
const { globalState } = this.pos;
|
||||
if (globalState.numpadMode === "quantity" && globalState.disallowLineQuantityChange()) {
|
||||
@@ -230,6 +233,8 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
|
||||
order.add_orderline(newLine);
|
||||
}
|
||||
}
|
||||
// FIXME POSREF this is dead code, check if we need the business logic that's left in here
|
||||
// If we do it should be in the model.
|
||||
async onClickPay() {
|
||||
const { globalState } = this.pos;
|
||||
if (globalState.get_order().server_id) {
|
||||
@@ -258,29 +263,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) {
|
||||
Promise.reject(error);
|
||||
}
|
||||
}
|
||||
if (
|
||||
globalState
|
||||
.get_order()
|
||||
.orderlines.some(
|
||||
(line) =>
|
||||
line.get_product().tracking !== "none" && !line.has_valid_product_lot()
|
||||
) &&
|
||||
(globalState.picking_type.use_create_lots || globalState.picking_type.use_existing_lots)
|
||||
) {
|
||||
const { confirmed } = await this.popup.add(ConfirmPopup, {
|
||||
title: this.env._t("Some Serial/Lot Numbers are missing"),
|
||||
body: this.env._t(
|
||||
"You are trying to sell products with serial/lot numbers, but some of them are not set.\nWould you like to proceed anyway?"
|
||||
),
|
||||
confirmText: this.env._t("Yes"),
|
||||
cancelText: this.env._t("No"),
|
||||
});
|
||||
if (confirmed) {
|
||||
this.pos.showScreen("PaymentScreen");
|
||||
}
|
||||
} else {
|
||||
this.pos.showScreen("PaymentScreen");
|
||||
}
|
||||
this.currentOrder.pay();
|
||||
}
|
||||
switchPane() {
|
||||
this.state.mobile_pane = this.state.mobile_pane === "left" ? "right" : "left";
|
||||
|
||||
@@ -3169,6 +3169,9 @@ export class Order extends PosModel {
|
||||
return Object.keys(this.getOrderChanges()).length ? true : false;
|
||||
}
|
||||
async pay() {
|
||||
if (!this.orderlines.length) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.orderlines.some(
|
||||
(line) => line.get_product().tracking !== "none" && !line.has_valid_product_lot()
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="MobileOrderWidget" owl="1">
|
||||
<div class="switchpane">
|
||||
<button class="btn-switchpane" t-on-click="clickPay">
|
||||
<h1>Pay</h1>
|
||||
<span><t t-esc="total" /></span>
|
||||
</button>
|
||||
<button class="btn-switchpane secondary" t-on-click="props.onSwitchPane">
|
||||
<h1>Review</h1>
|
||||
<span><t t-esc="items_number"/> items</span>
|
||||
</button>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -13,7 +13,7 @@
|
||||
Customer
|
||||
</t>
|
||||
</button>
|
||||
<button class="button pay validation pay-order-button" t-on-click="props.actionToTrigger ? this.props.actionToTrigger : () => this.clickPay()">
|
||||
<button class="button pay validation pay-order-button" t-on-click="props.actionToTrigger ? this.props.actionToTrigger : () => pos.globalState.get_order().pay()">
|
||||
<div class="pay-circle" t-att-class="{ 'highlight': this.highlightPay }">
|
||||
<i class="oi oi-chevron-right" role="img" aria-label="Pay" title="Pay" />
|
||||
</div>
|
||||
|
||||
@@ -31,10 +31,16 @@
|
||||
</div>
|
||||
<div class="rightpane" t-if="!ui.isSmall || state.mobile_pane === 'right'">
|
||||
<ProductsWidget />
|
||||
<MobileOrderWidget
|
||||
t-if="ui.isSmall"
|
||||
pane="state.mobile_pane"
|
||||
onSwitchPane.bind="switchPane"/>
|
||||
<div t-if="ui.isSmall" class="switchpane">
|
||||
<button class="btn-switchpane" t-on-click="() => currentOrder.pay()">
|
||||
<h1>Pay</h1>
|
||||
<span t-esc="total"/>
|
||||
</button>
|
||||
<button class="btn-switchpane secondary" t-on-click="switchPane">
|
||||
<h1>Review</h1>
|
||||
<span><t t-esc="items"/> items</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user