diff --git a/addons/point_of_sale/static/src/js/Misc/MobileOrderWidget.js b/addons/point_of_sale/static/src/js/Misc/MobileOrderWidget.js deleted file mode 100644 index cd5410da5e2..00000000000 --- a/addons/point_of_sale/static/src/js/Misc/MobileOrderWidget.js +++ /dev/null @@ -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(); - } - } -} diff --git a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ActionpadWidget.js b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ActionpadWidget.js index bcdb7d25f30..760885d7564 100644 --- a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ActionpadWidget.js +++ b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ActionpadWidget.js @@ -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; } diff --git a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js index 909ad7bb78f..04eae8674c9 100644 --- a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js @@ -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"; diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 6558ac6e5f3..30816127b6a 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -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() diff --git a/addons/point_of_sale/static/src/xml/Misc/MobileOrderWidget.xml b/addons/point_of_sale/static/src/xml/Misc/MobileOrderWidget.xml deleted file mode 100644 index b2ec0c37658..00000000000 --- a/addons/point_of_sale/static/src/xml/Misc/MobileOrderWidget.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - Pay - - - - Review - items - - - - - diff --git a/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ActionpadWidget.xml b/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ActionpadWidget.xml index 04600cac90a..af3412fe880 100644 --- a/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ActionpadWidget.xml +++ b/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ActionpadWidget.xml @@ -13,7 +13,7 @@ Customer - + diff --git a/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ProductScreen.xml b/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ProductScreen.xml index 67f27776815..d61318901eb 100644 --- a/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ProductScreen.xml +++ b/addons/point_of_sale/static/src/xml/Screens/ProductScreen/ProductScreen.xml @@ -31,10 +31,16 @@ - + + + Pay + + + + Review + items + +