diff --git a/addons/l10n_co_pos/static/src/overrides/components/order_receipt/order_receipt.xml b/addons/l10n_co_pos/static/src/overrides/components/order_receipt/order_receipt.xml index ab1c86fbcdf..7cb7fd75825 100644 --- a/addons/l10n_co_pos/static/src/overrides/components/order_receipt/order_receipt.xml +++ b/addons/l10n_co_pos/static/src/overrides/components/order_receipt/order_receipt.xml @@ -3,8 +3,8 @@ - -
+ +
diff --git a/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml b/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml index fbe0cf8ae40..896c5e9fa3c 100644 --- a/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml +++ b/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml @@ -2,16 +2,16 @@ - +
-
+
- - + +
Old unit price: diff --git a/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.xml b/addons/l10n_gcc_pos/static/src/overrides/app/screens/receipt_screen/receipt/order_receipt.xml similarity index 52% rename from addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.xml rename to addons/l10n_gcc_pos/static/src/overrides/app/screens/receipt_screen/receipt/order_receipt.xml index 0cc8266c6f2..64a9a3fdfce 100644 --- a/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.xml +++ b/addons/l10n_gcc_pos/static/src/overrides/app/screens/receipt_screen/receipt/order_receipt.xml @@ -3,7 +3,7 @@ - +

@@ -15,87 +15,87 @@ - - !receipt.is_gcc_country + + !receiptData.receipt.is_gcc_country - -
-
Served by / خدم بواسطة
+ +
+
Served by / خدم بواسطة
- - !receipt.is_gcc_country + + !receiptData.receipt.is_gcc_country - -
+ +
Subtotal / الإجمالي الفرعي - +
- - !receipt.is_gcc_country + + !receiptData.receipt.is_gcc_country - -
+ +
TOTAL / الإجمالي - +
- - !receipt.is_gcc_country + + !receiptData.receipt.is_gcc_country - -
+ +
Rounding / التقريب - +
- - !receipt.is_gcc_country + + !receiptData.receipt.is_gcc_country - -
+ +
To Pay / للسداد - +
- - !receipt.is_gcc_country + + !receiptData.receipt.is_gcc_country - -
+ +
CHANGE / الباقي - +
- - !receipt.is_gcc_country + + !receiptData.receipt.is_gcc_country - -
+ +
Discounts / الخصومات - +
- Total Taxes / إجمالي الضرائب + Total Taxes / إجمالي الضرائب Total - !receipt.is_gcc_country + !receiptData.receipt.is_gcc_country - +
@@ -112,10 +112,10 @@ - !receipt.is_gcc_country + !receiptData.receipt.is_gcc_country -
+
Discount / الخصم
: %
diff --git a/addons/l10n_gcc_pos/static/src/overrides/app/screens/receipt_screen/receipt_screen.js b/addons/l10n_gcc_pos/static/src/overrides/app/screens/receipt_screen/receipt_screen.js new file mode 100644 index 00000000000..d4bdecec4cb --- /dev/null +++ b/addons/l10n_gcc_pos/static/src/overrides/app/screens/receipt_screen/receipt_screen.js @@ -0,0 +1,16 @@ +/** @odoo-module */ + +import { ReceiptScreen } from "@point_of_sale/app/screens/receipt_screen/receipt_screen"; +import { patch } from "@web/core/utils/patch"; + +patch(ReceiptScreen.prototype, { + get receiptData() { + const receiptData = super.receiptData; + const receipt = receiptData.receipt; + const country = receiptData.order.pos.company.country; + receipt.is_gcc_country = country + ? ["SA", "AE", "BH", "OM", "QA", "KW"].includes(country && country.code) + : false; + return receiptData; + }, +}); diff --git a/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.js b/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.js deleted file mode 100644 index 35620c73f08..00000000000 --- a/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.js +++ /dev/null @@ -1,16 +0,0 @@ -/** @odoo-module */ - -import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/receipt"; -import { patch } from "@web/core/utils/patch"; - -patch(OrderReceipt.prototype, { - get receiptEnv() { - const receipt_render_env = super.receiptEnv; - const receipt = receipt_render_env.receipt; - const country = receipt_render_env.order.pos.company.country; - receipt.is_gcc_country = country - ? ["SA", "AE", "BH", "OM", "QA", "KW"].includes(country && country.code) - : false; - return receipt_render_env; - }, -}); diff --git a/addons/l10n_in_pos/static/src/overrides/components/pos_receipt.xml b/addons/l10n_in_pos/static/src/overrides/components/pos_receipt.xml index 38401064627..221a6fc849f 100644 --- a/addons/l10n_in_pos/static/src/overrides/components/pos_receipt.xml +++ b/addons/l10n_in_pos/static/src/overrides/components/pos_receipt.xml @@ -2,13 +2,13 @@ - +
-
- +
+
Phone: - +

@@ -18,7 +18,7 @@
- +
HSN Code: diff --git a/addons/l10n_sa_pos/static/src/overrides/components/order_receipt/order_receipt.xml b/addons/l10n_sa_pos/static/src/overrides/components/order_receipt/order_receipt.xml index 84ae9c16c63..31fbcfb459f 100644 --- a/addons/l10n_sa_pos/static/src/overrides/components/order_receipt/order_receipt.xml +++ b/addons/l10n_sa_pos/static/src/overrides/components/order_receipt/order_receipt.xml @@ -2,20 +2,20 @@ - - + +
- + Simplified Tax Invoice - + فاتورة ضريبية مبسطة diff --git a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js index 195e649cb2e..e911d796bcb 100644 --- a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js +++ b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js @@ -17,7 +17,8 @@ import { PaymentScreenNumpad } from "@point_of_sale/app/screens/payment_screen/n import { PaymentScreenPaymentLines } from "@point_of_sale/app/screens/payment_screen/payment_lines/payment_lines"; import { PaymentScreenStatus } from "@point_of_sale/app/screens/payment_screen/payment_status/payment_status"; import { usePos } from "@point_of_sale/app/store/pos_hook"; -import { Component, useState } from "@odoo/owl"; +import { Component, useState, useRef } from "@odoo/owl"; +import { renderToElement } from "@web/core/utils/render"; export class PaymentScreen extends Component { static template = "point_of_sale.PaymentScreen"; @@ -35,6 +36,7 @@ export class PaymentScreen extends Component { this.report = useService("report"); this.notification = useService("pos_notification"); this.hardwareProxy = useService("hardware_proxy"); + this.orderReceipt = useRef("order-receipt"); this.payment_methods_from_config = this.pos.payment_methods.filter((method) => this.pos.config.payment_method_ids.includes(method.id) ); @@ -279,7 +281,7 @@ export class PaymentScreen extends Component { await this.postPushOrderResolve(syncOrderResult.map((res) => res.id)); } - this.afterOrderValidation(!!syncOrderResult && syncOrderResult.length > 0); + await this.afterOrderValidation(!!syncOrderResult && syncOrderResult.length > 0); } async postPushOrderResolve(ordersServerId) { const postPushResult = await this._postPushOrderResolve(this.currentOrder, ordersServerId); @@ -310,7 +312,38 @@ export class PaymentScreen extends Component { } // Always show the next screen regardless of error since pos has to // continue working even offline. - this.pos.showScreen(this.nextScreen); + let nextScreen = this.nextScreen; + + if ( + nextScreen === "ReceiptScreen" && + !this.currentOrder._printed && + this.pos.config.iface_print_auto + ) { + const invoiced_finalized = this.currentOrder.is_to_invoice() + ? this.currentOrder.finalized + : true; + + if (this.hardwareProxy.printer && invoiced_finalized) { + const orderReceipt = renderToElement("point_of_sale.OrderReceipt", { + receiptData: { + ...this.pos.get_order().getOrderReceiptEnv(), + }, + pos: this.pos, + env: this.env, + }); + + // Need to await to have the result in case of automatic skip screen. + const printResult = await this.hardwareProxy.printer.printReceipt(orderReceipt); + + if (printResult.successful && this.pos.config.iface_print_skip_screen) { + this.pos.removeOrder(this.currentOrder); + this.pos.add_new_order(); + nextScreen = "ProductScreen"; + } + } + } + + this.pos.showScreen(nextScreen); } get nextScreen() { return !this.error ? "ReceiptScreen" : "ProductScreen"; diff --git a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.xml b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.xml index 88461ef912a..a3014974359 100644 --- a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.xml +++ b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.xml @@ -32,7 +32,6 @@
-
diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js index f5e574f82fb..302a1146fc9 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js @@ -21,7 +21,7 @@ export class AbstractReceiptScreen extends Component { async _printReceipt() { if (this.hardwareProxy.printer) { const printResult = await this.hardwareProxy.printer.printReceipt( - this.orderReceipt.el.firstChild + this.orderReceipt.el.firstChild.firstChild ); if (printResult.successful) { return true; diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/order_receipt.xml b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/order_receipt.xml new file mode 100644 index 00000000000..8ae38b1c76d --- /dev/null +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/order_receipt.xml @@ -0,0 +1,245 @@ + + + + +
+ + +
+
+ +

+ +

+
+
+
+ +
+
+ +
Tel:
+
+ +
:
+
+ +
+
+ +
+
+ +
+
+ +
+
--------------------------------
+
Served by
+
+
+
+

+ + +
+ +
+ + + +
--------
+
+
Subtotal
+ +
+ + +
+
+
+ + +
--------
+
+
+ TOTAL + +
+ +
+ Rounding + +
+
+ To Pay + +
+
+

+ + + + +
+ + +
+
+
+ +
+ CHANGE + +
+
+ + + + +
+ Discounts + +
+
+
+ + VAT% + VAT + ExVAT + Total + + + % + + + + + + + + + + + +
+ + + + +
+
+ + + + + + +
+ + -> + +
+
+ +
+ + + + + + +
+
+ +
+ Discount: % +
+
+
+ + + x + +
+ + +
+
+ +
+ +
+
+ +
+
    + +
  • + SN +
  • +
    +
+
+
+
+
+
+ diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.js deleted file mode 100644 index 0e66bb87c92..00000000000 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.js +++ /dev/null @@ -1,61 +0,0 @@ -/** @odoo-module */ - -import { usePos } from "@point_of_sale/app/store/pos_hook"; -import { WrappedProductNameLines } from "@point_of_sale/app/screens/receipt_screen/receipt/wrapped_product_name"; -import { Component, onWillUpdateProps } from "@odoo/owl"; - -export class OrderReceipt extends Component { - static components = { WrappedProductNameLines }; - static template = "point_of_sale.OrderReceipt"; - - setup() { - this.pos = usePos(); - this._receiptEnv = this.props.order.getOrderReceiptEnv(); - - onWillUpdateProps((nextProps) => { - this._receiptEnv = nextProps.order.getOrderReceiptEnv(); - }); - } - get receipt() { - return this.receiptEnv.receipt; - } - get orderlines() { - return this.receiptEnv.orderlines; - } - get paymentlines() { - return this.receiptEnv.paymentlines; - } - get isTaxIncluded() { - return Math.abs(this.receipt.subtotal - this.receipt.total_with_tax) <= 0.000001; - } - get receiptEnv() { - return this._receiptEnv; - } - get shippingDate() { - return this.receiptEnv.shippingDate; - } - /** - * @param {number} lineId - * @returns {boolean} true if the line is part of a combo - */ - lineIsPartOfCombo(lineId) { - return this.orderlines.find((l) => l.id === lineId || l.cid === lineId).isPartOfCombo(); - } - - /** - * @param {object} line item of the array given by `this.receiptEnv.orderlines` - * @returns {object} the corresponding tax objects from `pos.taxes_by_id` - */ - getOrderlineTaxes(line) { - return Object.keys(line.tax_details).map((taxId) => this.pos.taxes_by_id[taxId]); - } - - /** - * Override this method to customize the tax letter mapping. - * @param {array} taxes array of tax objects from `pos.taxes_by_id` - * @returns {string} the tax letter - */ - getTaxLetter(...taxes) { - return ""; - } -} diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.xml b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.xml deleted file mode 100644 index a95eecf9064..00000000000 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.xml +++ /dev/null @@ -1,244 +0,0 @@ - - - - -
- - -
-
- -

- -

-
-
-
- -
-
- -
Tel:
-
- -
:
-
- -
-
- -
-
- -
-
- -
-
--------------------------------
-
Served by
-
-
-
-

- - - -
- -
- - - - -
--------
-
-
Subtotal
- -
- - -
-
-
- - -
--------
-
-
- TOTAL - -
- -
- Rounding - -
-
- To Pay - -
-
-

- - - - -
- - -
-
-
- -
- CHANGE - -
-
- - - - -
- Discounts - -
-
-
- - VAT% - VAT - ExVAT - Total - - - % - - - - - - - - - - - -
- - - - -
-
- - -
- - -> - -
-
- -
- - - - - - -
-
- -
- Discount: % -
-
-
- - - x - -
- - -
-
- -
- -
-
- -
-
    - -
  • - SN -
  • -
    -
-
-
-
- - - diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/wrapped_product_name.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/wrapped_product_name.js deleted file mode 100644 index a1acc383701..00000000000 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/wrapped_product_name.js +++ /dev/null @@ -1,7 +0,0 @@ -/** @odoo-module */ - -import { Component } from "@odoo/owl"; - -export class WrappedProductNameLines extends Component { - static template = "point_of_sale.WrappedProductNameLines"; -} diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/wrapped_product_name.xml b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/wrapped_product_name.xml deleted file mode 100644 index 942384e94c0..00000000000 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/wrapped_product_name.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js index 82047005f15..cb908ecc40b 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js @@ -5,15 +5,13 @@ import { useErrorHandlers } from "@point_of_sale/app/utils/hooks"; import { AbstractReceiptScreen } from "@point_of_sale/app/screens/receipt_screen/abstract_receipt_screen"; import { OfflineErrorPopup } from "@point_of_sale/app/errors/popups/offline_error_popup"; import { registry } from "@web/core/registry"; -import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/receipt"; -import { onMounted, useRef, status, useState, onWillStart } from "@odoo/owl"; +import { useRef, useState, onWillStart } from "@odoo/owl"; import { usePos } from "@point_of_sale/app/store/pos_hook"; import { useService } from "@web/core/utils/hooks"; import { BasePrinter } from "@point_of_sale/app/printer/base_printer"; export class ReceiptScreen extends AbstractReceiptScreen { static template = "point_of_sale.ReceiptScreen"; - static components = { OrderReceipt }; setup() { super.setup(); @@ -30,23 +28,6 @@ export class ReceiptScreen extends AbstractReceiptScreen { this.orderUiState.inputEmail = this.orderUiState.inputEmail || (partner && partner.email) || ""; - onMounted(() => { - // Here, we send a task to the event loop that handles - // the printing of the receipt when the component is mounted. - // We are doing this because we want the receipt screen to be - // displayed regardless of what happen to the handleAutoPrint - // call. - setTimeout(async () => { - if (status(this) === "mounted") { - const images = this.orderReceipt.el.getElementsByTagName("img"); - for (const image of images) { - await image.decode(); - } - await this.handleAutoPrint(); - } - }, 0); - }); - onWillStart(async () => { // When the order is paid, if there is still a part of the order // to send in preparation it is automatically sent @@ -55,7 +36,9 @@ export class ReceiptScreen extends AbstractReceiptScreen { } }); } - + get receiptData() { + return this.pos.get_order().getOrderReceiptEnv(); + } _addNewOrder() { this.pos.add_new_order(); } @@ -113,28 +96,6 @@ export class ReceiptScreen extends AbstractReceiptScreen { get ticketScreen() { return { name: "TicketScreen" }; } - whenClosing() { - this.orderDone(); - } - /** - * This function is called outside the rendering call stack. This way, - * we don't block the displaying of ReceiptScreen when it is mounted; additionally, - * any error that can happen during the printing does not affect the rendering. - */ - async handleAutoPrint() { - if (this._shouldAutoPrint()) { - const currentOrder = this.currentOrder; - await this.printReceipt(); - if ( - this.currentOrder && - this.currentOrder === currentOrder && - currentOrder._printed && - this._shouldCloseImmediately() - ) { - this.whenClosing(); - } - } - } orderDone() { this.pos.removeOrder(this.currentOrder); this._addNewOrder(); @@ -168,19 +129,6 @@ export class ReceiptScreen extends AbstractReceiptScreen { this.buttonPrintReceipt.el.className = "fa fa-print"; } } - _shouldAutoPrint() { - return this.pos.config.iface_print_auto && !this.currentOrder._printed; - } - _shouldCloseImmediately() { - var invoiced_finalized = this.currentOrder.is_to_invoice() - ? this.currentOrder.finalized - : true; - return ( - this.hardwareProxy.printer && - this.pos.config.iface_print_skip_screen && - invoiced_finalized - ); - } async _sendReceiptToCustomer() { const printer = new BasePrinter(); const receiptString = this.orderReceipt.el.firstChild; diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.xml b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.xml index 82c0dacab06..949c6e44004 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.xml +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.xml @@ -34,7 +34,9 @@
- +
+ +
diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.js index 29a3f24ffda..145e7b2b7f9 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.js +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.js @@ -3,35 +3,26 @@ import { usePos } from "@point_of_sale/app/store/pos_hook"; import { AbstractReceiptScreen } from "@point_of_sale/app/screens/receipt_screen/abstract_receipt_screen"; import { registry } from "@web/core/registry"; -import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/receipt"; export class ReprintReceiptScreen extends AbstractReceiptScreen { static template = "point_of_sale.ReprintReceiptScreen"; - static components = { OrderReceipt }; static storeOnOrder = false; setup() { super.setup(); this.pos = usePos(); - owl.onMounted(this.onMounted); - } - onMounted() { - this.printReceipt(); } + confirm() { this.pos.showScreen("TicketScreen", { reuseSavedUIState: true }); } - async printReceipt() { - const { iface_print_skip_screen } = this.pos.config; - if (this.hardwareProxy.printer && iface_print_skip_screen) { - const result = await this._printReceipt(); - if (result) { - this.pos.showScreen("TicketScreen", { reuseSavedUIState: true }); - } - } - } + async tryReprint() { await this._printReceipt(); } + + get receiptData() { + return this.pos.get_order().getOrderReceiptEnv(); + } } registry.category("pos_screens").add("ReprintReceiptScreen", ReprintReceiptScreen); diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.xml b/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.xml index c74f798d61a..8d82ab0b243 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.xml +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/reprint_receipt_screen.xml @@ -16,7 +16,9 @@ Print Receipt
- +
+ +
diff --git a/addons/point_of_sale/static/src/app/screens/ticket_screen/reprint_receipt_button/reprint_receipt_button.js b/addons/point_of_sale/static/src/app/screens/ticket_screen/reprint_receipt_button/reprint_receipt_button.js index 34eed301815..61da54d2b35 100644 --- a/addons/point_of_sale/static/src/app/screens/ticket_screen/reprint_receipt_button/reprint_receipt_button.js +++ b/addons/point_of_sale/static/src/app/screens/ticket_screen/reprint_receipt_button/reprint_receipt_button.js @@ -2,17 +2,36 @@ import { usePos } from "@point_of_sale/app/store/pos_hook"; import { Component } from "@odoo/owl"; +import { renderToElement } from "@web/core/utils/render"; +import { useService } from "@web/core/utils/hooks"; +import { useAsyncLockedMethod } from "@point_of_sale/app/utils/hooks"; export class ReprintReceiptButton extends Component { static template = "point_of_sale.ReprintReceiptButton"; setup() { this.pos = usePos(); + this.hardwareProxy = useService("hardware_proxy"); + this.click = useAsyncLockedMethod(this.click); } + async click() { if (!this.props.order) { return; } - this.pos.showScreen("ReprintReceiptScreen", { order: this.props.order }); + if (this.hardwareProxy.printer) { + const orderReceipt = renderToElement("point_of_sale.OrderReceipt", { + receiptData: { + ...this.pos.get_order().getOrderReceiptEnv(), + }, + pos: this.pos, + env: this.env, + }); + + // Need to await to have the result in case of automatic skip screen. + await this.hardwareProxy.printer.printReceipt(orderReceipt); + } else { + this.pos.showScreen("ReprintReceiptScreen", { order: this.props.order }); + } } } diff --git a/addons/point_of_sale/static/src/app/store/models.js b/addons/point_of_sale/static/src/app/store/models.js index a010113b0d4..479bc873369 100644 --- a/addons/point_of_sale/static/src/app/store/models.js +++ b/addons/point_of_sale/static/src/app/store/models.js @@ -819,6 +819,7 @@ export class Orderline extends PosModel { pack_lot_lines: this.get_lot_lines(), customer_note: this.get_customer_note(), taxed_lst_unit_price: this.get_taxed_lst_unit_price(), + isPartOfCombo: this.isPartOfCombo(), unitDisplayPriceBeforeDiscount: this.getUnitDisplayPriceBeforeDiscount(), }; } @@ -2666,9 +2667,15 @@ export class Order extends PosModel { */ getOrderReceiptEnv() { // Formerly get_receipt_render_env defined in ScreenWidget. + const receipt = this.export_for_printing(); + const isTaxIncluded = Math.abs(receipt.subtotal - receipt.total_with_tax) <= 0.000001; + const getOrderlineTaxes = (line) => + Object.keys(line.tax_details).map((taxId) => this.pos.taxes_by_id[taxId]); return { + getOrderlineTaxes: getOrderlineTaxes, + isTaxIncluded: isTaxIncluded, order: this, - receipt: this.export_for_printing(), + receipt: receipt, orderlines: this.get_orderlines(), paymentlines: this.get_paymentlines(), shippingDate: this.shippingDate ? this._exportShippingDateForPrinting() : false, diff --git a/addons/pos_loyalty/static/src/overrides/components/order_receipt/order_receipt.xml b/addons/pos_loyalty/static/src/overrides/components/order_receipt/order_receipt.xml index 302fc3a1d6d..1a50f9722f6 100644 --- a/addons/pos_loyalty/static/src/overrides/components/order_receipt/order_receipt.xml +++ b/addons/pos_loyalty/static/src/overrides/components/order_receipt/order_receipt.xml @@ -3,15 +3,15 @@ - - + +
--------------------------------

-
+

@@ -29,14 +29,14 @@
- +
------------------------

Coupon Codes
- +
diff --git a/addons/pos_mercury/static/src/overrides/components/order_receipt/order_receipt.xml b/addons/pos_mercury/static/src/app/screens/receipt_screen/receipt/order_receipt.xml similarity index 86% rename from addons/pos_mercury/static/src/overrides/components/order_receipt/order_receipt.xml rename to addons/pos_mercury/static/src/app/screens/receipt_screen/receipt/order_receipt.xml index db525bf6f71..1c531269269 100644 --- a/addons/pos_mercury/static/src/overrides/components/order_receipt/order_receipt.xml +++ b/addons/pos_mercury/static/src/app/screens/receipt_screen/receipt/order_receipt.xml @@ -2,7 +2,7 @@ - +
APPROVAL CODE: @@ -13,7 +13,7 @@ -
+

CARDHOLDER WILL PAY CARD ISSUER
ABOVE AMOUNT PURSUANT
diff --git a/addons/pos_mercury/static/src/app/screens/receipt_screen/receipt_screen.js b/addons/pos_mercury/static/src/app/screens/receipt_screen/receipt_screen.js new file mode 100644 index 00000000000..813e7602c3d --- /dev/null +++ b/addons/pos_mercury/static/src/app/screens/receipt_screen/receipt_screen.js @@ -0,0 +1,18 @@ +/** @odoo-module */ + +import { ReceiptScreen } from "@point_of_sale/app/screens/receipt_screen/receipt_screen"; +import { patch } from "@web/core/utils/patch"; + +patch(ReceiptScreen.prototype, { + get receiptData() { + const receiptData = super.receiptData; + + receiptData.hasPosMercurySignature = receiptData.paymentlines.some((line) => { + if (line.mercury_data) { + return true; + } + }); + + return receiptData; + }, +}); diff --git a/addons/pos_mercury/static/src/overrides/components/order_receipt/order_receipt.js b/addons/pos_mercury/static/src/overrides/components/order_receipt/order_receipt.js deleted file mode 100644 index c09d1bda49a..00000000000 --- a/addons/pos_mercury/static/src/overrides/components/order_receipt/order_receipt.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @odoo-module */ - -import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/receipt"; -import { patch } from "@web/core/utils/patch"; - -patch(OrderReceipt.prototype, { - /** - * The receipt has signature if one of the paymentlines - * is paid with mercury. - */ - get hasPosMercurySignature() { - for (const line of this.paymentlines) { - if (line.mercury_data) { - return true; - } - } - return false; - }, -}); diff --git a/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.js b/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.js index f1e3b7cc091..d6b1eea8c84 100644 --- a/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.js +++ b/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.js @@ -9,9 +9,6 @@ export class BillScreen extends ReceiptScreen { this.props.resolve({ confirmed: true, payload: null }); this.pos.closeTempScreen(); } - whenClosing() { - this.confirm(); - } /** * @override */ @@ -19,6 +16,14 @@ export class BillScreen extends ReceiptScreen { await super.printReceipt(); this.currentOrder._printed = false; } + + get isBill() { + return true; + } + + get receiptData() { + return this.pos.get_order().getOrderReceiptEnv(); + } } registry.category("pos_screens").add("BillScreen", BillScreen); diff --git a/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.xml b/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.xml index bbc0bdebee5..a579533c3b2 100644 --- a/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.xml +++ b/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.xml @@ -20,7 +20,9 @@ Print
- +
+ +
diff --git a/addons/pos_restaurant/static/src/app/control_buttons/print_bill_button/print_bill_button.js b/addons/pos_restaurant/static/src/app/control_buttons/print_bill_button/print_bill_button.js index 00b136faa46..c6d49554d23 100644 --- a/addons/pos_restaurant/static/src/app/control_buttons/print_bill_button/print_bill_button.js +++ b/addons/pos_restaurant/static/src/app/control_buttons/print_bill_button/print_bill_button.js @@ -3,13 +3,19 @@ import { usePos } from "@point_of_sale/app/store/pos_hook"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { Component } from "@odoo/owl"; +import { renderToElement } from "@web/core/utils/render"; +import { useService } from "@web/core/utils/hooks"; +import { useAsyncLockedMethod } from "@point_of_sale/app/utils/hooks"; export class PrintBillButton extends Component { static template = "pos_restaurant.PrintBillButton"; setup() { this.pos = usePos(); + this.hardwareProxy = useService("hardware_proxy"); + this.click = useAsyncLockedMethod(this.click); } + _isDisabled() { const order = this.pos.get_order(); if (!order) { @@ -17,8 +23,22 @@ export class PrintBillButton extends Component { } return order.get_orderlines().length === 0; } - click() { - this.pos.showTempScreen("BillScreen"); + + async click() { + if (this.hardwareProxy.printer) { + const orderReceipt = renderToElement("point_of_sale.OrderReceipt", { + receiptData: { + ...this.pos.get_order().getOrderReceiptEnv(), + }, + pos: this.pos, + env: this.env, + }); + + // Need to await to have the result in case of automatic skip screen. + await this.hardwareProxy.printer.printReceipt(orderReceipt); + } else { + this.pos.showTempScreen("BillScreen"); + } } } diff --git a/addons/pos_restaurant/static/src/overrides/components/receipt_screen/order_receipt/order_receipt.xml b/addons/pos_restaurant/static/src/overrides/components/receipt_screen/order_receipt/order_receipt.xml index 3bf831d9749..bb67c8de712 100644 --- a/addons/pos_restaurant/static/src/overrides/components/receipt_screen/order_receipt/order_receipt.xml +++ b/addons/pos_restaurant/static/src/overrides/components/receipt_screen/order_receipt/order_receipt.xml @@ -3,42 +3,42 @@ - +
PRO FORMA
- !props.isBill + !isBill - - at table + + at table - -
Guests:
+ +
Guests:
- +
For convenience, we are providing the following gratuity calculations:
15%
- +
20%
- +
25%
- +
diff --git a/addons/pos_self_order/static/src/common/self_order_service.js b/addons/pos_self_order/static/src/common/self_order_service.js index c432a43fb75..c3b12d45ed4 100644 --- a/addons/pos_self_order/static/src/common/self_order_service.js +++ b/addons/pos_self_order/static/src/common/self_order_service.js @@ -9,7 +9,7 @@ import { getColor } from "@web/core/colors/colors"; import { categorySorter } from "@pos_self_order/common/utils"; export class selfOrderCommon extends Reactive { - async setup(env, rpc, notification, router, bus_service, cookie) { + async setup(env, { rpc, notification, router, bus_service, cookie, multi_tab }) { // services this.env = env; this.router = router; @@ -17,6 +17,7 @@ export class selfOrderCommon extends Reactive { this.notification = notification; this.bus_service = bus_service; this.cookie = cookie; + this.multi_tab = multi_tab; // data Object.assign(this, { diff --git a/addons/pos_self_order/static/src/kiosk/self_order_kiosk_service.js b/addons/pos_self_order/static/src/kiosk/self_order_kiosk_service.js index 612926d7a79..922881e2ad4 100644 --- a/addons/pos_self_order/static/src/kiosk/self_order_kiosk_service.js +++ b/addons/pos_self_order/static/src/kiosk/self_order_kiosk_service.js @@ -97,7 +97,7 @@ export class selfOrder extends selfOrderCommon { export const selfOrderService = { dependencies: ["rpc", "notification", "router", "bus_service", "cookie"], async start(env, { rpc, notification, router, bus_service, cookie }) { - return new selfOrder(env, rpc, notification, router, bus_service, cookie).ready; + return new selfOrder(env, { rpc, notification, router, bus_service, cookie }).ready; }, }; diff --git a/addons/pos_self_order/static/src/mobile/self_order_mobile_service.js b/addons/pos_self_order/static/src/mobile/self_order_mobile_service.js index 3501df2631d..dba542b8d47 100644 --- a/addons/pos_self_order/static/src/mobile/self_order_mobile_service.js +++ b/addons/pos_self_order/static/src/mobile/self_order_mobile_service.js @@ -208,7 +208,7 @@ export class SelfOrder extends selfOrderCommon { export const selfOrderService = { dependencies: ["rpc", "notification", "router"], async start(env, { rpc, notification, router }) { - return new SelfOrder(env, rpc, notification, router).ready; + return new SelfOrder(env, { rpc, notification, router }).ready; }, };