feat: increase product load limit and add order summary patches for optimized POS navigation

This commit is contained in:
Suherdy Yacob 2026-06-03 14:24:16 +07:00
parent 277d740996
commit 0dcd17039f
6 changed files with 78 additions and 4 deletions

View File

@ -28,6 +28,8 @@ Features
'pos_ui_optimization/static/src/app/components/order_display/order_display_patch.xml',
'pos_ui_optimization/static/src/app/screens/product_screen/product_screen_patch.js',
'pos_ui_optimization/static/src/app/screens/product_screen/product_screen_patch.xml',
'pos_ui_optimization/static/src/app/screens/product_screen/order_summary_patch.js',
'pos_ui_optimization/static/src/app/screens/product_screen/order_summary_patch.xml',
# Payment screen patches
'pos_ui_optimization/static/src/app/screens/payment_screen/payment_screen_patch.xml',
# Portrait mode — service must load first

View File

@ -0,0 +1,45 @@
/** @odoo-module **/
import { OrderSummary } from "@point_of_sale/app/screens/product_screen/order_summary/order_summary";
import { patch } from "@web/core/utils/patch";
patch(OrderSummary.prototype, {
get currentOrder() {
return this.pos.selectedOrder || null;
},
async updateSelectedOrderline({ buffer, key }) {
const order = this.pos.getOrder();
if (!order) {
return;
}
return super.updateSelectedOrderline(...arguments);
},
showUnbookButton() {
const order = this.pos.getOrder();
if (!order) {
return false;
}
if (this.pos.selectedTable) {
return (
this.pos.config.module_pos_restaurant &&
!this.pos.models["pos.order"].some(
(o) =>
o.table_id?.id === this.pos.selectedTable.id &&
o.finalized === false &&
!o.isBooked
) &&
order.lines.length === 0 &&
!order.hasCourses()
);
}
return (
this.pos.config.module_pos_restaurant &&
!order.finalized &&
order.isBooked &&
order.isEmpty() &&
!order.hasCourses()
);
}
});

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-inherit="point_of_sale.OrderSummary" t-inherit-mode="extension" owl="1">
<xpath expr="//OrderDisplay" position="attributes">
<attribute name="t-if">currentOrder</attribute>
</xpath>
</t>
</templates>

View File

@ -7,7 +7,7 @@ import { useEffect } from "@odoo/owl";
patch(ProductScreen.prototype, {
setup() {
super.setup();
this.state.displayedProductsCount = 40;
this.state.displayedProductsCount = 80;
const originalOnScroll = this.onScroll;
this.onScroll = (ev) => {
@ -15,22 +15,33 @@ patch(ProductScreen.prototype, {
originalOnScroll(ev);
}
const el = ev.target;
if (el && el.scrollTop + el.clientHeight >= el.scrollHeight - 200) {
if (el && el.scrollTop + el.clientHeight >= el.scrollHeight - 400) {
const totalCount = this.pos.productToDisplayByCateg.reduce((acc, cat) => acc + cat[1].length, 0);
if (this.state.displayedProductsCount < totalCount) {
this.state.displayedProductsCount += 40;
this.state.displayedProductsCount += 80;
}
}
};
useEffect(
() => {
this.state.displayedProductsCount = 40;
this.state.displayedProductsCount = 80;
},
() => [this.pos.searchProductWord, this.pos.selectedCategory]
);
},
get currentOrder() {
return this.pos.getOrder() || {
lines: [],
totalQuantity: 0,
isEmpty() { return true; },
getPartner() { return null; },
deselectOrderline() {},
assertEditable() {},
};
},
get productToDisplayByCategLimited() {
const fullList = this.pos.productToDisplayByCateg;
let count = 0;

View File

@ -7,5 +7,9 @@
<xpath expr="//ProductCard" position="attributes">
<attribute name="t-on-touchmove">longPressHandlers.onTouchEnd</attribute>
</xpath>
<xpath expr="//button[hasclass('pay-button')]" position="attributes">
<attribute name="t-if">!pos.scanning and currentOrder</attribute>
<attribute name="t-attf-class">{{ currentOrder &amp;&amp; currentOrder.isEmpty() ? 'btn-secondary' : 'btn-primary' }}</attribute>
</xpath>
</t>
</templates>

View File

@ -91,6 +91,10 @@
padding-bottom: 122px !important;
overflow: hidden;
.products-widget {
overflow: hidden !important;
}
.overflow-y-auto {
flex-grow: 1 !important;
flex-shrink: 1 !important;