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:)
This commit is contained in:
parent
91209dead4
commit
31a40e95d7
|
|
@ -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',
|
||||
|
|
|
|||
36
open_workshop_pos/static/src/js/ows_order_patch.js
Normal file
36
open_workshop_pos/static/src/js/ows_order_patch.js
Normal file
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
33
open_workshop_pos/static/src/xml/ows_voucher_codes_patch.xml
Normal file
33
open_workshop_pos/static/src/xml/ows_voucher_codes_patch.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<!-- Add voucher codes section after the receipt content -->
|
||||
<t t-name="point_of_sale.OrderReceipt" t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension">
|
||||
<xpath expr="//div[hasclass('pos-receipt')]" position="inside">
|
||||
<t t-if="props.data.voucherCodes and props.data.voucherCodes.length > 0">
|
||||
<div class="voucher-codes-section mt-3">
|
||||
<div class="text-center fw-bold fs-5 mb-2">================================</div>
|
||||
<div class="text-center fw-bold fs-4 mb-2">GUTSCHEIN-CODES</div>
|
||||
<div class="text-center fw-bold fs-5 mb-3">================================</div>
|
||||
|
||||
<t t-foreach="props.data.voucherCodes" t-as="voucher" t-key="voucher_index">
|
||||
<div class="voucher-code-item mb-3 p-2 border rounded">
|
||||
<div class="text-center fw-bold fs-1 mb-2" style="letter-spacing: 2px; font-family: monospace;">
|
||||
<t t-esc="voucher.code" />
|
||||
</div>
|
||||
<div class="text-center" t-if="voucher.name">
|
||||
<t t-esc="voucher.name" />
|
||||
</div>
|
||||
<div class="text-center fw-bold">
|
||||
Wert: <t t-esc="props.formatCurrency(voucher.value)" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<div class="text-center mt-3 fst-italic">
|
||||
Bitte bewahren Sie diesen Code gut auf!
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
Loading…
Reference in New Issue
Block a user