upgrade to odoo19

This commit is contained in:
Suherdy Yacob 2026-03-16 09:07:33 +07:00
commit c238ec5e77
5 changed files with 134 additions and 0 deletions

19
__manifest__.py Normal file
View File

@ -0,0 +1,19 @@
{
'name': 'POS UI Optimization',
'version': '1.0',
'category': 'Sales/Point of Sale',
'summary': 'Optimize POS UI for low-RAM devices with incremental rendering (Odoo 19).',
'depends': ['point_of_sale'],
'data': [],
'assets': {
'point_of_sale._assets_pos': [
'pos_ui_optimization/static/src/app/components/order_display/order_display_patch.js',
'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',
],
},
'installable': True,
'application': False,
'license': 'LGPL-3',
}

View File

@ -0,0 +1,45 @@
/** @odoo-module **/
import { OrderDisplay } from "@point_of_sale/app/components/order_display/order_display";
import { patch } from "@web/core/utils/patch";
import { useState, onMounted, onWillUnmount } from "@odoo/owl";
patch(OrderDisplay.prototype, {
setup() {
super.setup();
this.state = useState({ displayedCount: 20 });
onMounted(() => {
const scrollable = this.scrollableRef.el;
if (!scrollable) {
return;
}
this.onScroll = () => {
if (
scrollable.scrollTop + scrollable.clientHeight >=
scrollable.scrollHeight - 100
) {
if (this.state.displayedCount < this.comboSortedLines.length) {
this.state.displayedCount += 20;
}
}
};
scrollable.addEventListener("scroll", this.onScroll);
// Ensure selected line is visible by expanding displayedCount if needed
const selectedLineIndex = this.comboSortedLines.findIndex(l => l.selected);
if (selectedLineIndex >= this.state.displayedCount) {
this.state.displayedCount = selectedLineIndex + 1;
}
});
onWillUnmount(() => {
this.scrollableRef.el?.removeEventListener("scroll", this.onScroll);
});
},
get linesToDisplay() {
return this.comboSortedLines.slice(0, this.state.displayedCount);
}
});

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.OrderDisplay" t-inherit-mode="extension">
<xpath expr="//t[@t-set='lines']" position="attributes">
<attribute name="t-value">linesToDisplay</attribute>
</xpath>
</t>
</templates>

View File

@ -0,0 +1,54 @@
/** @odoo-module **/
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { patch } from "@web/core/utils/patch";
import { useEffect } from "@odoo/owl";
patch(ProductScreen.prototype, {
setup() {
super.setup();
this.state.displayedProductsCount = 40;
const originalOnScroll = this.onScroll;
this.onScroll = (ev) => {
if (originalOnScroll) {
originalOnScroll(ev);
}
const el = ev.target;
if (el && el.scrollTop + el.clientHeight >= el.scrollHeight - 200) {
const totalCount = this.pos.productToDisplayByCateg.reduce((acc, cat) => acc + cat[1].length, 0);
if (this.state.displayedProductsCount < totalCount) {
this.state.displayedProductsCount += 40;
}
}
};
useEffect(
() => {
this.state.displayedProductsCount = 40;
},
() => [this.pos.searchProductWord, this.pos.selectedCategory]
);
},
get productToDisplayByCategLimited() {
const fullList = this.pos.productToDisplayByCateg;
let count = 0;
const limitedList = [];
for (const [categ, products] of fullList) {
const remaining = this.state.displayedProductsCount - count;
if (remaining <= 0) {
break;
}
if (products.length <= remaining) {
limitedList.push([categ, products]);
count += products.length;
} else {
limitedList.push([categ, products.slice(0, remaining)]);
count += remaining;
break;
}
}
return limitedList;
}
});

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.ProductScreen" t-inherit-mode="extension" owl="1">
<xpath expr="//div[@t-foreach='pos.productToDisplayByCateg']" position="attributes">
<attribute name="t-foreach">productToDisplayByCategLimited</attribute>
</xpath>
</t>
</templates>