Skip to content

Commit 0c8c020

Browse files
committed
[ADD] pos_receipt: enable flexible and user-friendly receipt customization
This change introduces a user-centric framework for customizing POS receipt layouts, addressing the need for more flexible and visually appealing print formats. By allowing businesses to configure receipt appearance and content—such as layout styles, headers, footers, and logos—directly from POS settings or via a dedicated wizard, we significantly improve the adaptability of the POS module to various branding requirements. The enhancements also make receipt previews more intuitive, helping users visualize changes in real time and promoting better alignment between digital and physical touchpoints. These changes aim to improve usability, maintain consistency in receipt formatting across sessions, and offer a more intuitive configuration workflow aligned with real-world operational needs.
1 parent fbf9ee9 commit 0c8c020

15 files changed

+727
-0
lines changed

pos_receipt/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import models
4+
from . import wizard

pos_receipt/__manifest__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
'name': 'POS receipt',
3+
'version': '1.0',
4+
'depends': ['point_of_sale'],
5+
'data': [
6+
'security/ir.model.access.csv',
7+
'wizard/pos_receipt_wizard_views.xml',
8+
'views/res_config_settings_view.xml',
9+
'views/boxes_receipt.xml',
10+
'views/lined_receipt.xml',
11+
'views/light_receipt.xml',
12+
],
13+
'assets': {
14+
'point_of_sale._assets_pos': [
15+
'pos_receipt/static/src/**/*',
16+
],
17+
},
18+
'installable': True,
19+
'license': 'LGPL-3',
20+
}

pos_receipt/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import pos_config
2+
from . import res_config_settings

pos_receipt/models/pos_config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from odoo import fields, models
2+
3+
4+
class POSConfig(models.Model):
5+
_inherit = 'pos.config'
6+
7+
receipt_layout = fields.Selection([
8+
('light', 'Light'),
9+
('lined', 'Lined'),
10+
('boxes', 'Boxes'),
11+
], string="Receipt Layout", default='light')
12+
13+
receipt_logo = fields.Binary(string='Receipt Logo', related='company_id.logo', readonly=False)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from odoo import _, fields, models
2+
3+
4+
class ResConfigSettings(models.TransientModel):
5+
_inherit = 'res.config.settings'
6+
7+
receipt_layout = fields.Selection(related='pos_config_id.receipt_layout', readonly=False)
8+
9+
def action_pos_receipt_layout(self):
10+
return {
11+
'type': 'ir.actions.act_window',
12+
'name': _('Configure your pos receipt'),
13+
'res_model': 'pos.receipt.wizard',
14+
'view_mode': 'form',
15+
'target': 'new',
16+
'context': {'active_pos_config_id': self.pos_config_id.id, 'dialog_size': 'extra-large'},
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
pos_receipt.access_receipt_layout,access_receipt_layout,pos_receipt.model_pos_receipt_wizard,base.group_user,1,1,1,1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/order_receipt";
2+
import { patch } from "@web/core/utils/patch";
3+
import { usePos } from "@point_of_sale/app/store/pos_hook";
4+
5+
patch(OrderReceipt, {
6+
template: "pos_receipt.order_receipt_inherited"
7+
});
8+
9+
patch(OrderReceipt.prototype, {
10+
setup(){
11+
super.setup();
12+
this.pos = usePos();
13+
},
14+
15+
get orderQuantity() {
16+
return this.props.data.orderlines.reduce((acc, line) => acc + parseFloat(line.qty), 0);
17+
},
18+
19+
get order() {
20+
return this.pos.get_order()
21+
}
22+
});

pos_receipt/static/src/order_receipt_inherit.xml

Lines changed: 329 additions & 0 deletions
Large diffs are not rendered by default.

pos_receipt/views/boxes_receipt.xml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<template id="custom_pos_receipt_boxes">
4+
<div style="text-align: center; width: 300px; margin: auto; border: 1px solid black; padding: 10px;">
5+
<img t-if="logo" t-att-src="image_data_uri(logo)" alt="Logo" style="height: 70px; " />
6+
<p style="margin: 5px 0;">Odoo India Pvt Ltd<br />Infocity Gandhinagar<br />Tax Id:
7+
233300990223</p>
8+
<t t-esc="header" />
9+
<h2 style="margin: 5px 0;">701</h2>
10+
<t t-if="is_restaurant"> Served by MOG <br /> Table 5 Guest 3 </t>
11+
<table style="width: 100%; border-collapse: collapse; text-align: left;">
12+
<tr>
13+
<th style="border: 1px solid black;">No</th>
14+
<th style="border: 1px solid black;">Item</th>
15+
<th style="border: 1px solid black;">Amount</th>
16+
</tr>
17+
<tr>
18+
<td style="border: 1px solid black;">1</td>
19+
<td style="border: 1px solid black;">Margarita Pizza<br />3 X 200<br />HSN:
20+
2300976</td>
21+
<td style="border: 1px solid black;">$600</td>
22+
</tr>
23+
<tr>
24+
<td style="border: 1px solid black;">2</td>
25+
<td style="border: 1px solid black;">Bacon Burger<br />5 X 150</td>
26+
<td style="border: 1px solid black;">$750</td>
27+
</tr>
28+
<tr>
29+
<td style="border: 1px solid black;">3</td>
30+
<td style="border: 1px solid black;">Apple Pie<br />3 X 80<br />HSN: 2300976</td>
31+
<td style="border: 1px solid black;">$240</td>
32+
</tr>
33+
<tr>
34+
<td style="border: 1px solid black;">4</td>
35+
<td style="border: 1px solid black;">Cheese Burger<br />5 X 150<br />HSN:
36+
2300976</td>
37+
<td style="border: 1px solid black;">$750</td>
38+
</tr>
39+
</table>
40+
<div class="border-bottom border-dark py-1 mb-2" style="font-size: 12px;">
41+
<div class="d-flex justify-content-between small">
42+
<span>Total Qty 12</span>
43+
<span>Sub Total $1625</span>
44+
</div>
45+
</div>
46+
<div class="text-end mb-2 fw-bold small border-bottom border-dark"
47+
style="font-size: 12px;">
48+
Cash $1625
49+
</div>
50+
<table style="width: 100%; border-collapse: collapse; text-align: left;">
51+
<tr>
52+
<th>Tax</th>
53+
<th>Amount</th>
54+
<th>Base</th>
55+
<th>Total</th>
56+
</tr>
57+
<tr>
58+
<td>SGST 2.5%</td>
59+
<td>40.2</td>
60+
<td>1584.8</td>
61+
<td>1625</td>
62+
</tr>
63+
<tr>
64+
<td>CGST 2.5%</td>
65+
<td>40.2</td>
66+
<td>1584.8</td>
67+
<td>1625</td>
68+
</tr>
69+
</table>
70+
<t t-esc="footer" />
71+
<p style="margin: 5px 0;">Odoo Point of Sale</p>
72+
<p style="margin: 5px 0;">Order 0001-003-0004</p>
73+
<p style="margin: 5px 0;">04/06/2024 08:30:24</p>
74+
</div>
75+
</template>
76+
</odoo>

pos_receipt/views/light_receipt.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<template id="custom_receipt_static_light" t-name="custom_receipt_static">
4+
<div style="font-family: Arial, sans-serif; width: 350px; margin: auto; text-align: center; border: 1px solid #ddd; padding: 10px;">
5+
<img t-if="logo" t-att-src="image_data_uri(logo)" alt="Logo" style="height: 70px; "/>
6+
<p style="margin: 5px 0; font-size: 12px;">
7+
Tel: +1 555-555-5556<br/>
8+
9+
http://www.example.com
10+
</p>
11+
<t t-esc="header"/>
12+
<h1 style="margin: 10px 0;">301</h1>
13+
<t t-if="is_restaurant">
14+
Served by MOG <br/>
15+
Table 5 Guest 3
16+
</t>
17+
<table style="width: 100%; text-align: left; font-size: 14px;">
18+
<tr><td><b>Margarita Pizza</b></td><td style="text-align: right;">$ 140.00</td></tr>
19+
<tr><td><span style="border: 1px solid #000; padding: 2px 5px;">1.00</span> x $140.00 / Units</td></tr>
20+
21+
<tr><td><b>Bacon Burger</b></td><td style="text-align: right;">$ 33.00</td></tr>
22+
<tr><td><span style="border: 1px solid #000; padding: 2px 5px;">1.00</span> x $33.00 / Units</td></tr>
23+
24+
<tr><td><b>Apple Pie</b></td><td style="text-align: right;">$ 85.00</td></tr>
25+
<tr><td><span style="border: 1px solid #000; padding: 2px 5px;">1.00</span> x $85.00 / Units</td></tr>
26+
</table>
27+
<hr/>
28+
<table style="width: 100%; text-align: left; font-size: 14px;">
29+
<tr><td>TOTAL</td><td style="text-align: right;">$ 258.00</td></tr>
30+
<tr><td>Cash</td><td style="text-align: right;">$ 258.00</td></tr>
31+
</table>
32+
<t t-esc="footer"/>
33+
<p style="margin-top: 10px; font-size: 12px;">Powered by Odoo</p>
34+
<p style="font-size: 12px;">Order 00003-001-0001<br/>03/19/2025 17:55:58</p>
35+
</div>
36+
</template>
37+
</odoo>

0 commit comments

Comments
 (0)