From 31a40e95d7f3ff3d2ebd9f06e587cb0916ef61e9 Mon Sep 17 00:00:00 2001 From: "matthias.lotz" Date: Tue, 6 Jan 2026 14:48:09 +0100 Subject: [PATCH] Add voucher codes display in POS receipt - Create ows_order_patch.js to collect voucher codes from orderlines - Add voucher codes section at end of receipt with large readable format - Include voucher code, product name, and value for each voucher - Move partner name logic from receipt_header_patch to order_patch - Add German labels (GUTSCHEIN-CODES, Wert:) --- open_workshop_pos/__manifest__.py | 2 ++ .../static/src/js/ows_order_patch.js | 36 +++++++++++++++++++ .../static/src/js/ows_receipt_header_patch.js | 18 ++-------- .../src/xml/ows_voucher_codes_patch.xml | 33 +++++++++++++++++ 4 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 open_workshop_pos/static/src/js/ows_order_patch.js create mode 100644 open_workshop_pos/static/src/xml/ows_voucher_codes_patch.xml diff --git a/open_workshop_pos/__manifest__.py b/open_workshop_pos/__manifest__.py index efc4180..8809bf6 100644 --- a/open_workshop_pos/__manifest__.py +++ b/open_workshop_pos/__manifest__.py @@ -39,6 +39,7 @@ Autor: HobbyHimmel 'open_workshop_pos/static/src/js/ows_machine_access_list.js', 'open_workshop_pos/static/src/js/ows_product_screen_template_patch.js', 'open_workshop_pos/static/src/js/ows_product_screen_default_category.js', + 'open_workshop_pos/static/src/js/ows_order_patch.js', 'open_workshop_pos/static/src/js/ows_receipt_header_patch.js', # XML Templates @@ -48,6 +49,7 @@ Autor: HobbyHimmel 'open_workshop_pos/static/src/xml/ows_product_screen_template_patch.xml', 'open_workshop_pos/static/src/xml/ows_product_card_patch.xml', 'open_workshop_pos/static/src/xml/ows_receipt_header_patch.xml', + 'open_workshop_pos/static/src/xml/ows_voucher_codes_patch.xml', # CSS 'open_workshop_pos/static/src/css/pos.css', diff --git a/open_workshop_pos/static/src/js/ows_order_patch.js b/open_workshop_pos/static/src/js/ows_order_patch.js new file mode 100644 index 0000000..1277e98 --- /dev/null +++ b/open_workshop_pos/static/src/js/ows_order_patch.js @@ -0,0 +1,36 @@ +/** @odoo-module **/ + +import { PosOrder } from "@point_of_sale/app/models/pos_order"; +import { patch } from "@web/core/utils/patch"; + +// Patch the PosOrder to collect voucher codes from orderlines +patch(PosOrder.prototype, { + export_for_printing(baseUrl, headerData) { + const result = super.export_for_printing(baseUrl, headerData); + + // Add partner name to headerData if partner exists + const partner = this.get_partner(); + if (partner && result.headerData) { + result.headerData.partnerName = partner.name; + } + + // Collect all voucher codes from orderlines + const voucherCodes = []; + for (const line of this.lines) { + if (line.voucher_code) { + voucherCodes.push({ + code: line.voucher_code, + name: line.product_id?.display_name || '', + value: line.get_price_with_tax() + }); + } + } + + // Add voucher codes to result if any exist + if (voucherCodes.length > 0) { + result.voucherCodes = voucherCodes; + } + + return result; + } +}); diff --git a/open_workshop_pos/static/src/js/ows_receipt_header_patch.js b/open_workshop_pos/static/src/js/ows_receipt_header_patch.js index a00d169..1d8fae0 100644 --- a/open_workshop_pos/static/src/js/ows_receipt_header_patch.js +++ b/open_workshop_pos/static/src/js/ows_receipt_header_patch.js @@ -1,19 +1,5 @@ /** @odoo-module */ -import { PosOrder } from "@point_of_sale/app/models/pos_order"; -import { patch } from "@web/core/utils/patch"; +// This file is now deprecated - order patching moved to ows_order_patch.js +// Keeping for backwards compatibility -// Patch the export_for_printing method to include partner data -patch(PosOrder.prototype, { - export_for_printing(baseUrl, headerData) { - const result = super.export_for_printing(baseUrl, headerData); - - // Add partner name to headerData if partner exists - const partner = this.get_partner(); - if (partner && result.headerData) { - result.headerData.partnerName = partner.name; - } - - return result; - } -}); diff --git a/open_workshop_pos/static/src/xml/ows_voucher_codes_patch.xml b/open_workshop_pos/static/src/xml/ows_voucher_codes_patch.xml new file mode 100644 index 0000000..c192239 --- /dev/null +++ b/open_workshop_pos/static/src/xml/ows_voucher_codes_patch.xml @@ -0,0 +1,33 @@ + + + + + + +
+
================================
+
GUTSCHEIN-CODES
+
================================
+ + +
+
+ +
+
+ +
+
+ Wert: +
+
+
+ +
+ Bitte bewahren Sie diesen Code gut auf! +
+
+
+
+
+