Strange behavior POS module search

Hi, I have a strange issue with search in POS. Looks like some string combination will fail the search.
Please refer to below screenshot

I typed “JA” in search field and it show all items starts with “JA”. This is correct

I typed “JAC”. It show all items start with “JAC”. This is also correct

I typed “JAS” and it does not shown anything. If you check my first screenshot, I have a few items with name started in “JAS”. “JAR” also does not work.

I’ve just recently upgrade from V8 to V9 though, it could be the hiccup in upgrade process.
Anyone encounter similar issue?

ERPNext: v9.2.22 (master)
Frappe Framework: v9.2.23 (master)
I’m using Chrome.

Thanks.

I’m try to query directly into the db using sql I found in point_of_sale.py and it show the right result.
I’m at loss here, anyone can point me where should I check next?

Thanks.

@fresthy

Can you please create github issue, we’ll check.

Hi Rohit,
Thanks for the reply. I’m hesitate to create a github issue because it doesn’t seems like a bug in the code, but an issue on my sides (cache? upgrade issue?).

I have another finding.
I tried to create a new item, I named it as ‘JASA SEMPROT KARBU’, and suddenly I can search using ‘JAS’ in my POS correctly.
My other search using ‘JAR’ still does not show the correct result though, but think I can fix it using the same workaround.

Is there any kind of indexing/cache that refreshed when I created a new item?

I’ve tried clearing my browser cache before and it does not solve the issue.
I also run these command with no avail.

bench clear-cache
bench clear-website-cache
sudo supervisorctl stop all
sudo supervisorctl start all

Thanks.

I have a feeling that if the result in POS search is divisable by 4, the last row is omitted.

As I’m not proficient in phyton, could anyone see if these code below have issues?
It’s from point_of_sale.js

render_items(items) {
	let _items = items || this.items;

	const all_items = Object.values(_items).map(item => this.get_item_html(item));
	let row_items = [];

	const row_container = '<div class="image-view-row">';
	let curr_row = row_container;

	for (let i=0; i < all_items.length; i++) {
		// wrap 4 items in a div to emulate
		// a row for clusterize
		if(i % 4 === 0 && i !== 0) {
			curr_row += '</div>';
			row_items.push(curr_row);
			curr_row = row_container;
		}
		curr_row += all_items[i];

		if(i == all_items.length - 1 && all_items.length % 4 !== 0) {
			row_items.push(curr_row);
		}
	}

	this.clusterize.update(row_items);
}
2 Likes

Yes you’re right I also able to replicate the issue in my local account and soon will fix it

Hi Rohit,

Thanks for your help.
Do I still need to create a github issue?

Thanks.

@fresthy

I’ve fixed the issue and soon we’ll release it.