Skip to content

[ADD] pos_receipt: created multiple layout styles for POS order receipts #851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pos_receipt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
15 changes: 15 additions & 0 deletions pos_receipt/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "POS Receipt",
"version": "1.0",
"depends": ["point_of_sale"],
"data": [
"security/ir.model.access.csv",
"views/custom_lined_layout.xml",
"views/custom_boxes_layout.xml",
"views/custom_light_layout.xml",
"views/pos_reciept_views.xml",
"wizard/pos_receipt_layout.xml",
],
"assets": {"point_of_sale._assets_pos": ["pos_receipt/static/src/**/*"]},
"license": "LGPL-3",
}
2 changes: 2 additions & 0 deletions pos_receipt/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import pos_config
from . import res_config_settings
17 changes: 17 additions & 0 deletions pos_receipt/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import models, fields


class PosConfig(models.Model):
_inherit = "pos.config"

receipt_layout = fields.Selection(
[("light", "Light"), ("boxes", "Boxes"), ("lined", "Lined")],
string="Select Layout",
default="light",
)
receipt_logo = fields.Binary(
string="Company Logo",
related="company_id.logo",
readonly=False,
help="A logo that will be printed in the receipt.",
)
21 changes: 21 additions & 0 deletions pos_receipt/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from odoo import models, fields


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

receipt_layout = fields.Selection(
related="pos_config_id.receipt_layout", readonly=False
)

def open_pos_receipt_config_wizard(self):
return {
"type": "ir.actions.act_window",
"name": "Configure Receipt",
"res_model": "pos.receipt.layout",
"view_mode": "form",
"target": "new",
"context": {
"active_pos_config_id": self.pos_config_id.id,
},
}
2 changes: 2 additions & 0 deletions pos_receipt/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_pos_receipt_layout,access_receipt_layout,model_pos_receipt_layout,base.group_user,1,1,1,1
24 changes: 24 additions & 0 deletions pos_receipt/static/src/pos_order_receipt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { patch } from "@web/core/utils/patch";
import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/order_receipt";
import { usePos } from "@point_of_sale/app/store/pos_hook";

patch(OrderReceipt, {
template: "pos_receipt.order_receipt_inherited",
});
patch(OrderReceipt.prototype, {
setup() {
super.setup();
this.pos = usePos();
},

get order() {
return this.pos.get_order();
},

get orderQuntity() {
return this.props.order.orderlines.reduce(
(sum, line) => sum + line.quantity,
0
);
},
});
335 changes: 335 additions & 0 deletions pos_receipt/static/src/pos_order_receipt.xml

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions pos_receipt/views/custom_boxes_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="custom_pos_receipt_boxed">
<div
style="text-align: center; width: 300px; margin: auto; border: 1px solid black; padding: 10px;">
<img t-if="logo" t-att-src="image_data_uri(logo)" alt="Logo" style="height: 70px; " />
<p style="margin: 5px 0;">Odoo India Pvt Ltd<br />Infocity Gandhinagar<br />Tax Id:
233300990223</p>
<t t-esc="header" />
<h2 style="margin: 5px 0;">701</h2>
<t t-if="is_restaurant"> Served by MOG <br /> Table 5 Guest 3 </t>
<table style="width: 100%; border-collapse: collapse; text-align: left;">
<tr>
<th style="border: 1px solid black;">No</th>
<th style="border: 1px solid black;">Item</th>
<th style="border: 1px solid black;">Amount</th>
</tr>
<tr>
<td style="border: 1px solid black;">1</td>
<td style="border: 1px solid black;">Margarita Pizza<br />3 X 200<br />HSN:
2300976</td>
<td style="border: 1px solid black;">$600</td>
</tr>
<tr>
<td style="border: 1px solid black;">2</td>
<td style="border: 1px solid black;">Bacon Burger<br />5 X 150</td>
<td style="border: 1px solid black;">$750</td>
</tr>
<tr>
<td style="border: 1px solid black;">3</td>
<td style="border: 1px solid black;">Apple Pie<br />3 X 80<br />HSN: 2300976</td>
<td style="border: 1px solid black;">$240</td>
</tr>
<tr>
<td style="border: 1px solid black;">4</td>
<td style="border: 1px solid black;">Cheese Burger<br />5 X 150<br />HSN:
2300976</td>
<td style="border: 1px solid black;">$750</td>
</tr>
</table>
<div class="border-bottom border-dark py-1 mb-2" style="font-size: 12px;">
<div class="d-flex justify-content-between small">
<span>Total Qty 12</span>
<span>Sub Total $1625</span>
</div>
</div>
<div class="text-end mb-2 fw-bold small border-bottom border-dark"
style="font-size: 12px;">
Cash $1625
</div>
<table style="width: 100%; border-collapse: collapse; text-align: left;">
<tr>
<th>Tax</th>
<th>Amount</th>
<th>Base</th>
<th>Total</th>
</tr>
<tr>
<td>SGST 2.5%</td>
<td>40.2</td>
<td>1584.8</td>
<td>1625</td>
</tr>
<tr>
<td>CGST 2.5%</td>
<td>40.2</td>
<td>1584.8</td>
<td>1625</td>
</tr>
</table>
<t t-esc="footer" />
<p style="margin: 5px 0;">Odoo Point of Sale</p>
<p style="margin: 5px 0;">Order 0001-003-0004</p>
<p style="margin: 5px 0;">04/06/2024 08:30:24</p>
</div>
</template>
</odoo>
62 changes: 62 additions & 0 deletions pos_receipt/views/custom_light_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="custom_receipt_light" t-name="custom_receipt_static">
<div
style="font-family: Arial, sans-serif; width: 350px; margin: auto; text-align: center; border: 1px solid #ddd; padding: 10px;">
<img t-if="logo" t-att-src="image_data_uri(logo)" alt="Logo" style="height: 70px; " />
<p style="margin: 5px 0; font-size: 12px;"> Tel: +1 555-555-5556<br />
[email protected]<br /> http://www.example.com </p>
<t t-esc="header" />
<h1 style="margin: 10px 0;">701</h1>
<t t-if="is_restaurant"> Served by MOG <br /> Table 5 Guest 3 </t>
<table style="width: 100%; text-align: left; font-size: 14px;">
<tr>
<td>
<b>Margarita Pizza</b>
</td>
<td style="text-align: right;">$ 140.00</td>
</tr>
<tr>
<td><span style="border: 1px solid #000; padding: 2px 5px;">1.00</span> x
$140.00 / Units</td>
</tr>

<tr>
<td>
<b>Bacon Burger</b>
</td>
<td style="text-align: right;">$ 33.00</td>
</tr>
<tr>
<td><span style="border: 1px solid #000; padding: 2px 5px;">1.00</span> x $33.00
/ Units</td>
</tr>

<tr>
<td>
<b>Apple Pie</b>
</td>
<td style="text-align: right;">$ 85.00</td>
</tr>
<tr>
<td><span style="border: 1px solid #000; padding: 2px 5px;">1.00</span> x $85.00
/ Units</td>
</tr>
</table>
<hr />
<table style="width: 100%; text-align: left; font-size: 14px;">
<tr>
<td>TOTAL</td>
<td style="text-align: right;">$ 258.00</td>
</tr>
<tr>
<td>Cash</td>
<td style="text-align: right;">$ 258.00</td>
</tr>
</table>
<t t-esc="footer" />
<p style="margin-top: 10px; font-size: 12px;">Powered by Odoo</p>
<p style="font-size: 12px;">Order 00003-001-0001<br />03/19/2025 17:55:58</p>
</div>
</template>
</odoo>
106 changes: 106 additions & 0 deletions pos_receipt/views/custom_lined_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="custom_receipt_lined" t-name="custom_receipt_handwritten">
<div
style="width: 320px; margin: auto; border: 2px solid black; padding: 10px; text-align: center;">
<img t-if="logo" t-att-src="image_data_uri(logo)" alt="Logo" style="height: 70px; " />
<div style="font-size: 12px; line-height: 1.5;"> Odoo India pvt ltd<br /> Infocity
Gandhinagar<br />
<strong>Tax Id: 2233004900223</strong>
</div>
<t t-esc="header" />
<h1 style="margin: 10px 0; font-size: 22px; font-weight: bold;">701</h1>
<t t-if="is_restaurant"> Served by MOG <br /> Table 5 Guest 3 </t>
<table
style="width: 100%; font-size: 12px; text-align: left; border-collapse: collapse; margin-top: 10px;">
<thead class="border-top border-bottom border-dark">
<tr>
<th>No</th>
<th>Item</th>
<th>Qty</th>
<th>Prices</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Margarita Pizza</td>
<td>3</td>
<td>200</td>
<td>600</td>
</tr>
<tr>
<td>2</td>
<td>Bacon Burger</td>
<td>5</td>
<td>150</td>
<td>750</td>
</tr>
<tr>
<td>3</td>
<td>Apple Pie</td>
<td>2</td>
<td>100</td>
<td>200</td>
</tr>
<tr>
<td>4</td>
<td>Cheese Burger</td>
<td>1</td>
<td>75</td>
<td>75</td>
</tr>
</tbody>
</table>
<div class="border-top border-dark py-1 mb-2">
<div class="d-flex justify-content-between small">
<span>Total Qty
12
</span>
<span class="bg-dark text-white">Sub Total $
1625
</span>
</div>
</div>
<div class="text-end mb-2 fw-bold small">
Bank
1625
</div>

<table
style="width: 100%; font-size: 12px; text-align: left; border-collapse: collapse; margin-top: 10px;">
<thead>
<tr>
<th>Tax</th>
<th>Amount</th>
<th>Base</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<i>SGST 2.5%</i>
</td>
<td>40.2</td>
<td>1584.8</td>
<td>1625</td>
</tr>
<tr>
<td>
<i>CGST 2.5%</i>
</td>
<td>40.2</td>
<td>1584.8</td>
<td>1625</td>
</tr>
</tbody>
</table>
<t t-esc="footer" />
<div style="text-align: center; font-size: 12px; margin-top: 10px;">
<strong>Odoo Point of Sale</strong><br /> Order 0001-003-0004<br /> 04/06/2024
08:30:24 </div>
</div>
</template>
</odoo>
25 changes: 25 additions & 0 deletions pos_receipt/views/pos_reciept_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="res_config_settings_view_inherit_form" model="ir.ui.view">
<field name="name">res.config.settings.view.inherit.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//block[@id='pos_bills_and_receipts_section']/setting"
position="replace">
<setting id="layout_settings" string="Receipt Layout"
help="Choose the layout of your receipt">
<field name="receipt_layout" />
<br />
<button name="open_pos_receipt_config_wizard"
string="Configure Receipt Layout"
type="object"
icon="oi-arrow-right"
class="btn-link"
>
</button>
</setting>
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions pos_receipt/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_receipt_layout
Loading