Hide Header & Footer on Basic Receipt, Show Cashier Name, Left Padding set to Default, Show Note on Basic Receipt
This commit is contained in:
parent
246100f4a6
commit
57b6040ed4
11
README.md
11
README.md
@ -10,11 +10,11 @@ This custom module is designed for Odoo 19 to override and customize the standar
|
||||
2. **Custom Ticket Prefix:**
|
||||
Replaces the default "Ticket" text prefix with "NO" on the main receipt reference sequence (e.g., instead of "Ticket 0001", it prints "NO 0001").
|
||||
|
||||
3. **Hide Cashier Name:**
|
||||
Hides the "Served by: [Cashier Name]" section from the receipt header for a cleaner look.
|
||||
3. **Custom "Pro Forma" Text:**
|
||||
When using the Early Receipt or Bill printing feature (before payment is finalized), Odoo natively prints "Pro forma receipt". This module replaces that text with an attention-grabbing **"!!! INI ADALAH TAGIHAN SEMENTARA, BUKAN BUKTI PEMBAYARAN !!!"**.
|
||||
|
||||
4. **Custom "Pro Forma" Text:**
|
||||
When using the Early Receipt or Bill printing feature (before payment is finalized), Odoo natively prints "Pro forma receipt". This module replaces that text with an attention-grabbing **"!!! INI ADALAH TAGIHAN SEMENTARA, BUKAN BUKTI PEMBAYARAN !!!"**. Furthermore, this text is explicitly hidden when printing a Basic Receipt (gift receipt without prices).
|
||||
4. **Basic Receipt Improvements:**
|
||||
When printing a Basic Receipt (e.g. gift receipt without prices), this module hides the receipt header, footer, and the "Pro Forma" text. It also ensures that both the **Customer Note** and the **Internal Note** are fully visible.
|
||||
|
||||
5. **Address & Email Removal:**
|
||||
Hides the detailed company/branch address and the company email from the receipt footer, keeping the receipt concise.
|
||||
@ -25,6 +25,9 @@ This custom module is designed for Odoo 19 to override and customize the standar
|
||||
7. **Remove Odoo Branding:**
|
||||
Hides the "Powered by Odoo" text and logo from the bottom of the receipt footer.
|
||||
|
||||
8. **Print Margin Adjustments:**
|
||||
Removes the top, right, and bottom margins from the print page so the content aligns closely with the paper edges, while preserving the default left margin.
|
||||
|
||||
## Technical Details
|
||||
|
||||
The module utilizes Odoo's OWL `xpath` inheritance mechanism to modify the front-end QWeb templates dynamically.
|
||||
|
||||
@ -12,11 +12,12 @@ This module customizes the printed receipt in the Point of Sale module to match
|
||||
Key Features:
|
||||
- **Tracking Number**: Hides the tracking number in the receipt header.
|
||||
- **Ticket Prefix**: Changes the "Ticket" prefix to "NO" in the header reference.
|
||||
- **Cashier Name**: Hides the "Served by" (cashier name) in the receipt header.
|
||||
- **Address & Email**: Hides the company/branch address and email in the receipt footer.
|
||||
- **Phone Prefix**: Changes the "Tel:" prefix to "Contact:" for the company phone number in the footer.
|
||||
- **Pro Forma Receipt**: Changes the default "Pro forma receipt" text to "!!! INI ADALAH TAGIHAN SEMENTARA, BUKAN BUKTI PEMBAYARAN !!!" for early/unpaid bills, and explicitly hides this text when printing a Basic Receipt.
|
||||
- **Pro Forma Receipt**: Changes the default "Pro forma receipt" text to "!!! INI ADALAH TAGIHAN SEMENTARA, BUKAN BUKTI PEMBAYARAN !!!" for early/unpaid bills.
|
||||
- **Basic Receipt Improvements**: Hides the "Pro forma receipt" text, receipt header, and receipt footer on Basic Receipts. Ensures both Customer Notes and Internal Notes are fully visible on the printed Basic Receipt.
|
||||
- **Odoo Branding**: Removes the "Powered by Odoo" text in the receipt footer.
|
||||
- **Print Margin**: Removes the top, right, and bottom margins from the print page, ensuring the content aligns closely with the paper edges while keeping the default left margin.
|
||||
""",
|
||||
'depends': ['point_of_sale', 'pos_restaurant'],
|
||||
'data': [],
|
||||
@ -24,6 +25,7 @@ Key Features:
|
||||
'point_of_sale._assets_pos': [
|
||||
'pos_custom_receipt/static/src/xml/receipt_overrides.xml',
|
||||
'pos_custom_receipt/static/src/css/receipt.css',
|
||||
'pos_custom_receipt/static/src/js/orderline.js',
|
||||
],
|
||||
},
|
||||
'installable': True,
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
@media print {
|
||||
@page {
|
||||
margin: 0 !important;
|
||||
margin-top: 0 !important;
|
||||
margin-right: 0 !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
body, html {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.pos-receipt {
|
||||
padding: 0 !important;
|
||||
padding-top: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
padding-bottom: 0 !important;
|
||||
margin: 0 !important;
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
@ -15,6 +19,8 @@
|
||||
}
|
||||
|
||||
.pos-receipt {
|
||||
padding: 0 !important;
|
||||
padding-top: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
padding-bottom: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
20
static/src/js/orderline.js
Normal file
20
static/src/js/orderline.js
Normal file
@ -0,0 +1,20 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { Orderline } from "@point_of_sale/app/components/orderline/orderline";
|
||||
|
||||
patch(Orderline.prototype, {
|
||||
get lineScreenValues() {
|
||||
const res = super.lineScreenValues;
|
||||
// In POS, the internal note (line.note) is typically shown only in display mode.
|
||||
// We override this to also include the parsed internalNote when printing receipts.
|
||||
if (this.props.mode === "receipt" && this.line.note) {
|
||||
try {
|
||||
res.internalNote = JSON.parse(this.line.note);
|
||||
} catch (e) {
|
||||
res.internalNote = [{ text: this.line.note }]; // Fallback if not valid JSON
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
});
|
||||
@ -15,18 +15,27 @@
|
||||
</span>
|
||||
</xpath>
|
||||
|
||||
<!-- Hide Cashier (Served by) -->
|
||||
<xpath expr="//div[hasclass('cashier')]" position="replace">
|
||||
<div class="cashier d-none"></div>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<!-- Hide Address, Phone, Email, and Powered By from Receipt Footer -->
|
||||
<t t-name="pos_custom_receipt.OrderReceipt" t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension">
|
||||
|
||||
<!-- Remove padding and margin from main receipt container -->
|
||||
<!-- Remove padding and margin from main receipt container (keep left padding default) -->
|
||||
<xpath expr="//div[hasclass('pos-receipt')]" position="attributes">
|
||||
<attribute name="class">pos-receipt p-0 m-0</attribute>
|
||||
<attribute name="class">pos-receipt pt-0 pe-0 pb-0 ps-2 m-0</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Hide header on basic receipt -->
|
||||
<xpath expr="//ReceiptHeader" position="attributes">
|
||||
<attribute name="t-if">!props.basic_receipt</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Show order note on basic receipt -->
|
||||
<xpath expr="//li[@t-if='line.customerNote']" position="replace">
|
||||
<li t-if="line.customer_note || line.customerNote" class="customer-note w-100 p-2 my-1 rounded text-break">
|
||||
<i class="fa fa-sticky-note me-1" role="img" aria-label="Customer Note" title="Customer Note"/>
|
||||
<t t-esc="line.customer_note || line.customerNote" />
|
||||
</li>
|
||||
</xpath>
|
||||
|
||||
<!-- Hide Address (Branch Address) -->
|
||||
@ -56,6 +65,20 @@
|
||||
<!-- Powered by Odoo is hidden -->
|
||||
</xpath>
|
||||
|
||||
<!-- Hide footer components on basic receipt -->
|
||||
<xpath expr="//div[@t-if='order.config.receipt_footer']" position="attributes">
|
||||
<attribute name="t-if">!props.basic_receipt and order.config.receipt_footer</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('after-footer')]" position="attributes">
|
||||
<attribute name="t-if">!props.basic_receipt</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//t[@t-if='order.shipping_date']" position="attributes">
|
||||
<attribute name="t-if">!props.basic_receipt and order.shipping_date</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('d-flex', 'gap-2', 'pt-3')][div[hasclass('w-50')]]" position="attributes">
|
||||
<attribute name="t-if">!props.basic_receipt</attribute>
|
||||
</xpath>
|
||||
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user