fix: pos search by term items price (backport #45006) (#45102)

* fix: load price list rate for pos search term

(cherry picked from commit 4b6cae156e)

# Conflicts:
#	erpnext/selling/page/point_of_sale/point_of_sale.py

* fix: load search term price with customer default price list

(cherry picked from commit 2beb485d77)

* chore: resolve conflict

---------

Co-authored-by: diptanilsaha <diptanil.dev@gmail.com>
Co-authored-by: ruthra kumar <ruthra@erpnext.com>
This commit is contained in:
mergify[bot]
2025-01-17 17:02:34 +05:30
committed by GitHub
parent a66d475b56
commit 524a8d77f7
2 changed files with 16 additions and 8 deletions

View File

@@ -51,13 +51,18 @@ def search_by_term(search_term, warehouse, price_list):
item_stock_qty = item_stock_qty // item.get("conversion_factor", 1)
item.update({"actual_qty": item_stock_qty})
price_filters = {
"price_list": price_list,
"item_code": item_code,
}
if batch_no:
price_filters["batch_no"] = batch_no
price = frappe.get_list(
doctype="Item Price",
filters={
"price_list": price_list,
"item_code": item_code,
},
fields=["uom", "currency", "price_list_rate"],
filters=price_filters,
fields=["uom", "currency", "price_list_rate", "batch_no"],
)
def __sort(p):

View File

@@ -325,13 +325,16 @@ erpnext.PointOfSale.ItemSelector = class {
}
filter_items({ search_term = "" } = {}) {
const selling_price_list = this.events.get_frm().doc.selling_price_list;
if (search_term) {
search_term = search_term.toLowerCase();
// memoize
this.search_index = this.search_index || {};
if (this.search_index[search_term]) {
const items = this.search_index[search_term];
this.search_index[selling_price_list] = this.search_index[selling_price_list] || {};
if (this.search_index[selling_price_list][search_term]) {
const items = this.search_index[selling_price_list][search_term];
this.items = items;
this.render_item_list(items);
this.auto_add_item && this.items.length == 1 && this.add_filtered_item_to_cart();
@@ -343,7 +346,7 @@ erpnext.PointOfSale.ItemSelector = class {
// eslint-disable-next-line no-unused-vars
const { items, serial_no, batch_no, barcode } = message;
if (search_term && !barcode) {
this.search_index[search_term] = items;
this.search_index[selling_price_list][search_term] = items;
}
this.items = items;
this.render_item_list(items);