From 524a8d77f75dade436043fbf344631262ca25eb4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:02:34 +0530 Subject: [PATCH] fix: pos search by term items price (backport #45006) (#45102) * fix: load price list rate for pos search term (cherry picked from commit 4b6cae156e2ece905158eaa649a9812d92bc87dd) # 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 2beb485d7753e8b0cf399cf9025ea349a5857a3e) * chore: resolve conflict --------- Co-authored-by: diptanilsaha Co-authored-by: ruthra kumar --- .../selling/page/point_of_sale/point_of_sale.py | 15 ++++++++++----- .../page/point_of_sale/pos_item_selector.js | 9 ++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index bc94d3b706e..7db9faacca2 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -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): diff --git a/erpnext/selling/page/point_of_sale/pos_item_selector.js b/erpnext/selling/page/point_of_sale/pos_item_selector.js index dba36bd2429..7021777d158 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_selector.js +++ b/erpnext/selling/page/point_of_sale/pos_item_selector.js @@ -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);