Skip to content
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
17 changes: 17 additions & 0 deletions pos_customer_display/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
'name': 'POS Customer Display',
'version': '1.0',
'category': 'Point of Sale',
'author': 'Mayankkumar Patel (pmad)',
'depends': ['point_of_sale'],
'installable': True,
'assets': {
'point_of_sale.assets_prod': [
'pos_customer_display/static/src/pos_customer_display.js'
],
'point_of_sale.customer_display_assets': [
'pos_customer_display/static/src/customer_display/*',
],
},
'license': 'LGPL-3',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="point_of_sale.CustomerDisplay" t-inherit="point_of_sale.CustomerDisplay" t-inherit-mode="extension">
<xpath expr="//div[@class='row' and @t-if='order.change']" position="after">
<div class="row">
<div class="col text-end">
Customer
</div>
<div class="col text-end text-muted"> <t t-esc="order.customerName" /> </div>
</div>

<div class="row mayank">
<t t-if="order.amountPerGuest">
<div class="col text-end">Amount</div>
<div class="col text-end text-muted">
<t t-esc="order.amountPerGuest.toFixed(2)" />
/ Guest
</div>
</t>
</div>
</xpath>

<xpath expr="//div[hasclass('o_customer_display_main')]/OrderWidget" position="replace">
<OrderWidget t-if="!order.finalized" lines="order.orderLines"/>
<t t-if="order.refundedOrderLines and order.isRefundOrder">
<p class="fs-3"> Refunds </p>
<OrderWidget lines="order.refundedOrderLines"/>
</t>
</xpath>
</t>

</templates>
30 changes: 30 additions & 0 deletions pos_customer_display/static/src/pos_customer_display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { patch } from "@web/core/utils/patch";
import { PosOrder } from "@point_of_sale/app/models/pos_order";

patch(PosOrder.prototype, {
setup() {
super.setup(...arguments);
this.guest_count = this.guest_count || 1;
},

getGuestCount() {
return this.guest_count || 1;
},

getCustomerDisplayData() {
const allOrderlines = this.getSortedOrderlines();
const refundedOrderLines = allOrderlines.filter((order) => order.refunded_orderline_id);
const nonRefundOrderLines = allOrderlines.filter((order) => !order.refunded_orderline_id);
const guestCount = this.getGuestCount();
const amountPerGuest = this.get_total_with_tax() / guestCount;

return {
...super.getCustomerDisplayData(),
customerName: this.get_partner_name() ? this.get_partner_name() : "Guest",
isRefundOrder: this._isRefundOrder(),
refundedOrderLines: refundedOrderLines.map((x) => x.getDisplayData()),
orderLines: nonRefundOrderLines.map((x) => x.getDisplayData()),
amountPerGuest: amountPerGuest,
};
},
});