Skip to content

Commit 996f642

Browse files
committed
[ADD] pos_customer_display: Enhance customer display and refund section.
This improvement extends the Point of Sale customer-facing screen by: - Displaying the customer's name (or Guest if not assigned) below the total/change section. - Showing the Amount / Guest if guest count is available and greater than zero. - Separating refunded order lines into a distinct Refund section below the regular items. JavaScript enhancements: - Patched PosOrder.getCustomerDisplayData() to include: - displayCustomerName - amountDividedPerGuest - refundedItems and activeItems XML template modifications: - Used XPath inheritance to insert new rows into the customer display. - Replaced the original OrderWidget to support line segregation. This update improves the clarity and transparency of the POS display for customers, especially in multi-guest and refund scenarios.
1 parent 96c3b20 commit 996f642

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

pos_customer_display/__init__.py

Whitespace-only changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
'name': 'POS Customer Display Name',
3+
'version': '1.0',
4+
'summary': 'Adding POS customer name on payment screeen',
5+
'description': """
6+
Showing Customer Diplay Name
7+
============================
8+
This module will show customer name on the customer display.
9+
10+
also will show refund lines septarately under refund subsection.
11+
""",
12+
'author': 'Raghav Agiwal',
13+
'depends': ['point_of_sale'],
14+
"assets": {
15+
'point_of_sale.assets_prod': [
16+
'pos_customer_display/static/src/pos_order.js',
17+
],
18+
'point_of_sale.customer_display_assets': [
19+
'pos_customer_display/static/src/customer_display/*',
20+
],
21+
},
22+
'installable': True,
23+
'license': 'LGPL-3'
24+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates id="template" xml:space="preserve">
3+
<t t-name="pos_customer.CustomerDisplay" t-inherit="point_of_sale.CustomerDisplay" t-inherit-mode="extension">
4+
<xpath expr="//div[@t-if='order.amount and !order.finalized']" position="inside">
5+
<div class="d-flex flex-column justify-content-center gap-1 w-100 w-sm-50 ms-auto">
6+
<div class="row fw-bolder">
7+
<div class="col text-end">Customer</div>
8+
<div class="col text-end" t-out="order.displayCustomerName"/>
9+
</div>
10+
<t t-if="order.amountDividedPerGuest">
11+
<div class="row fw-bolder">
12+
<div class="col text-end">Amount</div>
13+
<div class="col text-end" t-out="format_float(order.amountDividedPerGuest, 2)"/> / Guest
14+
</div>
15+
</t>
16+
</div>
17+
</xpath>
18+
19+
<xpath expr="//div[hasclass('o_customer_display_main')]/OrderWidget" position="replace">
20+
<OrderWidget t-if="!order.finalized" lines="order.activeItems"/>
21+
22+
<t t-if="order.refundedItems">
23+
<div class="mt-3 p-2 fw-bold">Refunded Items</div>
24+
<OrderWidget t-if="!order.finalized" lines="order.refundedItems"/>
25+
</t>
26+
</xpath>
27+
</t>
28+
</templates>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { patch } from "@web/core/utils/patch";
2+
import { PosOrder } from "@point_of_sale/app/models/pos_order";
3+
4+
patch(PosOrder.prototype, {
5+
getCustomerDisplayData() {
6+
const allLines = this.getSortedOrderlines();
7+
const returnedItems = allLines.filter(line => line.refunded_orderline_id);
8+
const saleItems = allLines.filter(line => !line.refunded_orderline_id);
9+
10+
const guests = this.guest_count || 0;
11+
const total = this.get_total_with_tax();
12+
const perGuestAmount = guests > 0 ? total / guests : null;
13+
14+
return {
15+
...super.getCustomerDisplayData(),
16+
17+
displayCustomerName: this.get_partner_name() || "Guest",
18+
amountDividedPerGuest: perGuestAmount,
19+
refundedItems: returnedItems.map(line => line.getDisplayData()),
20+
activeItems: saleItems.map(line => line.getDisplayData()),
21+
};
22+
},
23+
});

0 commit comments

Comments
 (0)