Skip to content

Commit 5bb239b

Browse files
committed
[IMP] pos_receipt: configure receipt layout
- Now users can configure their receipt format for each POS configuration. - Users can choose receipt type - Receipt Logo: Logo is also customizable in receipts now - Header and Footer: receipt with personalized header & footer content - Added support for selecting POS receipt layout (light, boxes, lined) dynamically based on backend configuration - Patched OrderReceipt component to apply the correct template at runtime
1 parent 3f0c4ab commit 5bb239b

File tree

10 files changed

+679
-11
lines changed

10 files changed

+679
-11
lines changed

pos_reciept_customize/__manifest__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
"data": [
1010
"security/ir.model.access.csv",
1111
"views/res_config_settings_views.xml",
12-
"wizard/reciepts_layout_view.xml",
12+
"wizard/receipts_layout_view.xml",
13+
"views/pos_retail_receipt_template.xml",
14+
"views/pos_restaurant_receipt_template.xml",
1315
],
16+
"assets": {
17+
"point_of_sale._assets_pos": [
18+
"pos_reciept_customize/static/src/**/*",
19+
]
20+
},
21+
"auto_install": True,
1422
}

pos_reciept_customize/models/pos_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ class PosConfig(models.Model):
1313
string="Receipt Layout",
1414
default="light",
1515
)
16-
receipt_logo = fields.Binary(string="Receipt Logo", default=lambda self: self.env.company.logo)
16+
receipt_logo = fields.Binary(related="company_id.logo", string="Receipt Logo")
1717
receipt_header_html = fields.Html(string="Header", default="", help="Custom HTML header for receipts")
1818
receipt_footer_html = fields.Html(string="Footer", default="", help="Custom HTML footer for receipts")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2-
pos_reciept_customize.access_receipts_layout,access_receipts_layout,pos_reciept_customize.model_receipts_layout,base.group_user,1,1,1,0
2+
pos_reciept_customize.access_receipts_layout,access_receipts_layout,model_receipts_layout,base.group_user,1,1,1,1
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
import { markup } from "@odoo/owl";
5+
6+
patch(OrderReceipt, {
7+
template: "pos_receipt_customize.order_view_inherited"
8+
});
9+
10+
patch(OrderReceipt.prototype, {
11+
setup() {
12+
this.pos = usePos();
13+
this.footer = markup(this.props.data.footer)
14+
},
15+
16+
get orderQuantity() {
17+
return this.props.data.orderlines.reduce((accumulator, line) => accumulator + parseFloat(line.qty), 0);
18+
},
19+
20+
get order() {
21+
return this.pos.get_order()
22+
}
23+
});

pos_reciept_customize/static/src/receipt/order_receipt.xml

Lines changed: 321 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<template id="report_restaurant_preview_light">
4+
<t t-call="pos_receipt.report_receipts_wizard_preview_light">
5+
<t t-set="additional_content">
6+
<div class="text-center">
7+
<p class="m-0">Served By MOG</p>
8+
<p class="m-1">Table 5 Guest 3</p>
9+
</div>
10+
</t>
11+
</t>
12+
</template>
13+
<template id="report_restaurant_preview_boxes">
14+
<t t-call="pos_receipt.report_receipts_wizard_preview_boxes">
15+
<t t-set="additional_content">
16+
<div class="text-center">
17+
<p class="m-0">Served By MOG</p>
18+
<p class="m-1">Table 5 Guest 3</p>
19+
</div>
20+
</t>
21+
</t>
22+
</template>
23+
<template id="report_restaurant_preview_lined">
24+
<t t-call="pos_receipt.report_receipts_wizard_preview_lined">
25+
<t t-set="additional_content">
26+
<div class="text-center">
27+
<p class="m-0">Served By MOG</p>
28+
<p class="m-1">Table 5 Guest 3</p>
29+
</div>
30+
</t>
31+
</t>
32+
</template>
33+
</odoo>
Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<template id="report_receipts_wizard_preview_light">
4+
<div class="receipt-preview-dark-receipt bg-white text-dark font-sans text-sm tracking-wide p-2 rounded-2 border border-3 border-dark shadow-lg" style="width: 430px; margin: 0 auto;">
5+
<div class="text-center mb-2">
6+
<div class="d-inline-block mb-1">
7+
<img t-if="receipt_logo" t-att-src="image_data_uri(receipt_logo)" alt="Logo" class="img-fluid" style="max-width: 60px; height: auto;"/>
8+
</div>
9+
<p class="mb-0 fw-bolder ">
10+
<t t-out="receipt_header or 'Odoo India Pvt Ltd'"/>
11+
</p>
12+
<p class="mb-0 ">Gandhinagar</p>
13+
<p class="mb-0 ">Tax Id: 44343235256</p>
14+
</div>
15+
<div class="text-center mb-2 fw-bolder ">
16+
701
17+
</div>
18+
<t t-out="additional_content"/>
19+
<div class="container mt-4">
20+
<div class="d-flex justify-content-between">
21+
<span>Burger</span>
22+
<span>$ 83.99</span>
23+
</div>
24+
<div class="item-details">
25+
4.00 x $ 12.63 / Units
26+
</div>
27+
<div class="d-flex justify-content-between mt-2">
28+
<span>Pizza</span>
29+
<span>$ 34.03</span>
30+
</div>
31+
<div class="item-details">
32+
7.00 x $ 6.68 / Units
33+
</div>
34+
<div class="d-flex justify-content-between mt-2">
35+
<span>Water</span>
36+
<span>$ 2.53</span>
37+
</div>
38+
<div class="item-details">
39+
2.00 x $ 5.0 / Units
40+
</div>
41+
<div class="d-flex justify-content-between mt-2">
42+
<span>Drink</span>
43+
<span>$ 2.53</span>
44+
</div>
45+
<div class="item-details">
46+
1.00 x $ 3.03 / Units
47+
</div>
48+
<div>
49+
<span>-----------------------------------</span>
50+
</div>
51+
<div class="d-flex justify-content-between">
52+
<span>Untaxed Amount</span>
53+
<span>$ 34.40</span>
54+
</div>
55+
<div class="d-flex justify-content-between">
56+
<span>Tax 15%</span>
57+
<span>$ 139.53</span>
58+
</div>
59+
<div>
60+
<span>-----------------------------------</span>
61+
</div>
62+
<div class="d-flex justify-content-between">
63+
<strong>TOTAL</strong>
64+
<strong>$ 148.77</strong>
65+
</div>
66+
<div class="d-flex justify-content-between">
67+
<span>Cash</span>
68+
<span>$ 808.57</span>
69+
</div>
70+
</div>
71+
<div class="text-center mt-2 ">
72+
<p class="mb-0">Odoo Point of Sale</p>
73+
<p class="mb-0">Order 0002-005-0001</p>
74+
<p class="mb-0">06/01/2024 06:50:20</p>
75+
<p class="mb-0">
76+
<t t-out="receipt_footer or ''"/>
77+
</p>
78+
</div>
79+
</div>
80+
</template>
81+
82+
<template id="report_receipts_wizard_preview_boxes">
83+
<div class="receipt-preview-dark-receipt bg-white text-dark font-sans text-sm tracking-wide p-2 rounded-2 border border-3 border-dark shadow-lg" style="width: 400px; margin: 0 auto;">
84+
<div class="text-center mb-2">
85+
<div class="d-inline-block mb-1">
86+
<img t-if="receipt_logo" t-att-src="image_data_uri(receipt_logo)" alt="Logo" class="img-fluid" style="max-width: 60px; height: auto;"/>
87+
</div>
88+
<p class="mb-0 fw-bolder ">
89+
<t t-out="receipt_header or 'Odoo India Pvt Ltd'"/>
90+
</p>
91+
<p class="mb-0 ">Gandhinagar</p>
92+
<p class="mb-0 ">Tax Id: 899247912</p>
93+
</div>
94+
<div class="text-center mb-2 fw-bolder ">
95+
701
96+
</div>
97+
<t t-out="additional_content"/>
98+
<table class="table table-bordered table-sm mb-2 border-dark">
99+
<thead>
100+
<tr>
101+
<th class="text-start fs-5 fw-bolder col-2">No</th>
102+
<th class="text-start fs-5 fw-bolder col-5">Item</th>
103+
<th class="text-end fs-5 fw-bolder col-4">Amount</th>
104+
</tr>
105+
</thead>
106+
<tbody>
107+
<tr>
108+
<td >1</td>
109+
<td > <span class="fw-bolder">Pizza</span>
110+
<br/>
111+
5 X 100
112+
<br/>
113+
HSN: 90234
114+
115+
</td>
116+
<td class="text-end ">$200</td>
117+
</tr>
118+
<tr>
119+
<td >2</td>
120+
<td > <span class="fw-bolder">Burger</span>
121+
<br/>
122+
4 X 120
123+
</td>
124+
<td class="text-end ">$450</td>
125+
</tr>
126+
<tr>
127+
<td >3</td>
128+
<td > <span class="fw-bolder">Apple Pie</span>
129+
<br/>
130+
6 X 40
131+
<br/>
132+
HSN: 5300761
133+
134+
</td>
135+
<td class="text-end ">$132</td>
136+
</tr>
137+
</tbody>
138+
</table>
139+
<div class="border-top border-bottom py-1 mb-2 border-dark">
140+
<div class="d-flex justify-content-between ">
141+
<span>Total Qty 19</span>
142+
<span>Sub Total $2526</span>
143+
</div>
144+
</div>
145+
<div class="text-end mb-2 fw-bolder ">
146+
Cash $433
147+
</div>
148+
<table class="table table-borderless table-sm mb-2">
149+
<thead>
150+
<tr>
151+
<th class="text-start fw-bolder">Tax</th>
152+
<th class="text-start fw-bolder">Amount</th>
153+
<th class="text-start fw-bolder">Base</th>
154+
<th class="text-end fw-bolder">Total</th>
155+
</tr>
156+
</thead>
157+
<tbody>
158+
<tr class="m-0 p-0">
159+
<td class=" m-0 p-0">SGST 2.5%</td>
160+
<td class=" m-0 p-0">52.2</td>
161+
<td class=" m-0 p-0">1884.8</td>
162+
<td class="text-end m-0 p-0">3421</td>
163+
</tr>
164+
<tr class="m-0 p-0">
165+
<td class=" m-0 p-0">CGST 2.5%</td>
166+
<td class=" m-0 p-0">40.2</td>
167+
<td class=" m-0 p-0">3251.8</td>
168+
<td class="text-end m-0 p-0">4312</td>
169+
</tr>
170+
</tbody>
171+
</table>
172+
<div class="text-center mt-2 ">
173+
<p class="mb-0">Odoo Point of Sale</p>
174+
<p class="mb-0">Order 0013-008-0003</p>
175+
<p class="mb-0">09/08/2024 03:40:24</p>
176+
<p class="mb-0">
177+
<t t-out="receipt_footer or ''"/>
178+
</p>
179+
</div>
180+
</div>
181+
</template>
182+
183+
<template id="report_receipts_wizard_preview_lined">
184+
<div class="receipt-preview-dark-receipt bg-white text-dark font-sans text-sm tracking-wide p-2 rounded-2 border border-3 border-dark shadow-lg" style="width: 400px; margin: 0 auto;">
185+
<div class="text-center mb-2">
186+
<div class="d-inline-block mb-1">
187+
<img t-if="receipt_logo" t-att-src="image_data_uri(receipt_logo)" alt="Logo" class="img-fluid" style="max-width: 60px; height: auto;"/>
188+
</div>
189+
<p class="mb-0 fw-bolder ">
190+
<t t-out="receipt_header or 'Odoo India Pvt Ltd'"/>
191+
</p>
192+
<p class="mb-0 ">Gandhinagar</p>
193+
<p class="mb-0 ">Tax Id: 8983268743</p>
194+
</div>
195+
<div class="text-center mb-2 fw-bolder ">
196+
701
197+
</div>
198+
<t t-out="additional_content"/>
199+
<table class="table table-sm table-borderless mb-2">
200+
<thead class="border-top border-bottom">
201+
<tr>
202+
<th class="text-start fw-bolder">No</th>
203+
<th class="text-start fw-bolder">Item</th>
204+
<th class="text-start fw-bolder">Qty</th>
205+
<th class="text-start fw-bolder">Price</th>
206+
<th class="text-end fw-bolder">Amount</th>
207+
</tr>
208+
</thead>
209+
<tbody>
210+
<tr>
211+
<td >1</td>
212+
<td >Pizza</td>
213+
<td >4</td>
214+
<td >600</td>
215+
<td class="text-end ">200</td>
216+
</tr>
217+
<tr>
218+
<td >2</td>
219+
<td >Burger</td>
220+
<td >6</td>
221+
<td >250</td>
222+
<td class="text-end ">1850</td>
223+
</tr>
224+
<tr>
225+
<td >3</td>
226+
<td >Apple Pie</td>
227+
<td >3</td>
228+
<td >100</td>
229+
<td class="text-end ">300</td>
230+
</tr>
231+
<tr>
232+
<td >4</td>
233+
<td >Burger</td>
234+
<td >6</td>
235+
<td >75</td>
236+
<td class="text-end ">650</td>
237+
</tr>
238+
</tbody>
239+
</table>
240+
<div class="border-top border-bottom py-1 mb-2">
241+
<div class="d-flex justify-content-between ">
242+
<span>Total Qty 10</span>
243+
<span>Sub Total 2436</span>
244+
</div>
245+
</div>
246+
<div class="text-end mb-2 fw-bolder ">
247+
Bank 1625
248+
</div>
249+
<table class="table table-borderless table-sm mb-2">
250+
<thead>
251+
<tr>
252+
<th class="text-start ">Tax</th>
253+
<th class="text-start ">Amount</th>
254+
<th class="text-start ">Base</th>
255+
<th class="text-end ">Total</th>
256+
</tr>
257+
</thead>
258+
<tbody>
259+
<tr class="m-0 p-0">
260+
<td class=" m-0 p-0">SGST 2.5%</td>
261+
<td class=" m-0 p-0">87.2</td>
262+
<td class=" m-0 p-0">2784.8</td>
263+
<td class="text-end m-0 p-0">8923</td>
264+
</tr>
265+
<tr class="m-0 p-0">
266+
<td class=" m-0 p-0">CGST 2.5%</td>
267+
<td class=" m-0 p-0">40.2</td>
268+
<td class=" m-0 p-0">1834.8</td>
269+
<td class="text-end m-0 p-0">2423</td>
270+
</tr>
271+
</tbody>
272+
</table>
273+
<div class="text-center mt-2 ">
274+
<p class="mb-0">Odoo Point of Sale</p>
275+
<p class="mb-0">Order 0001-003-0004</p>
276+
<p class="mb-0">04/06/2024 08:30:24</p>
277+
<p class="mb-0">
278+
<t t-out="receipt_footer or ''"/>
279+
</p>
280+
</div>
281+
</div>
282+
</template>
283+
</odoo>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Part of Odoo. See LICENSE file for full copyright and licensing details.
22

3-
from . import reciepts_layout
3+
from . import receipts_layout

0 commit comments

Comments
 (0)