Please, can someone suggest a quick fix for the new POS screen; maybe editing the pos.py file in the frappe-bench directory- so that it pulls a limited amount of records per query; here’s the situation; every other module runs fast except the POS and I think its about the way it pre-loads every item on the products DB! Can we remove this preloading? let the items only come when a search is made and then let it be limited to only searched items. sometimes this pr-loading makes the POS very slow and scanned items can take close to 5 seconds or more to be loaded. Our network is fast; other modules race very well.
I believe this issue can be fixed from a script in the frappe-bench folder, please guide. We just need to remove the auto loading of entire stocks.
Below is the pos.py file; what part of the code pulls everything? I tried the 99999; no luck, added a limit 10 to the select statement, no luck, please someone on the erpnext team should help; let the script pull only say 20 items for preview and then pull items as we scan or search without needing to pull probably 20MB+ everytime; including images
from __future__ import unicode_literals
import frappe
@frappe.whitelist()
def get_items(price_list, sales_or_purchase, item=None):
condition = “”
order_by = “”
args = {“price_list”: price_list}
if sales_or_purchase == "Sales":
condition = "i.is_sales_item=1"
else:
condition = "i.is_purchase_item=1"
if item:
# search serial no
item_code = frappe.db.sql("""select name as serial_no, item_code
from `tabSerial No` where name=%s""", (item), as_dict=1)
if item_code:
item_code[0]["name"] = item_code[0]["item_code"]
return item_code
# search barcode
item_code = frappe.db.sql("""select name, item_code from `tabItem`
where barcode=%s""",
(item), as_dict=1)
if item_code:
item_code[0]["barcode"] = item
return item_code
condition += " and ((CONCAT(i.name, i.item_name) like %(name)s) or (i.variant_of like %(name)s) or (i.item_group like %(name)s))"
order_by = """if(locate(%(_name)s, i.name), locate(%(_name)s, i.name), 99999),
if(locate(%(_name)s, i.item_name), locate(%(_name)s, i.item_name), 99999),
if(locate(%(_name)s, i.variant_of), locate(%(_name)s, i.variant_of), 99999),
if(locate(%(_name)s, i.item_group), locate(%(_name)s, i.item_group), 99999),"""
args["name"] = "%%%s%%" % frappe.db.escape(item)
args["_name"] = item.replace("%", "")
# locate function is used to sort by closest match from the beginning of the value
return frappe.db.sql("""select i.name, i.item_name, i.image,
item_det.price_list_rate, item_det.currency
from `tabItem` i LEFT JOIN
(select item_code, price_list_rate, currency from
`tabItem Price` where price_list=%(price_list)s) item_det
ON
(item_det.item_code=i.name or item_det.item_code=i.variant_of)
where
ifnull(i.has_variants, 0) = 0 and
{condition}
order by
{order_by}
i.name""".format(condition=condition, order_by=order_by), args, as_dict=1)