From 4cde77d8d8f4a6f833e4f28d7cd6f08ac0005474 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:05:48 +0530 Subject: [PATCH] fix: duplicate items and outdated item price in POS (backport #42978) (#44038) fix: duplicate items and outdated item price in POS (#42978) * fix: duplicate items and outdated item price in POS * fix: duplicate items and outdated item price in POS --formatter (cherry picked from commit 4ea2071265d524e1e09280ec8fe70d8861d1bda6) Co-authored-by: Nihantra C. Patel <141945075+Nihantra-Patel@users.noreply.github.com> --- erpnext/selling/page/point_of_sale/point_of_sale.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 2bb61a6439c..fad184d152c 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -159,6 +159,8 @@ def get_items(start, page_length, price_list, item_group, pos_profile, search_te if not items_data: return result + current_date = frappe.utils.today() + for item in items_data: uoms = frappe.get_doc("Item", item.item_code).get("uoms", []) @@ -167,12 +169,16 @@ def get_items(start, page_length, price_list, item_group, pos_profile, search_te item_price = frappe.get_all( "Item Price", - fields=["price_list_rate", "currency", "uom", "batch_no"], + fields=["price_list_rate", "currency", "uom", "batch_no", "valid_from", "valid_upto"], filters={ "price_list": price_list, "item_code": item.item_code, "selling": True, + "valid_from": ["<=", current_date], + "valid_upto": ["in", [None, "", current_date]], }, + order_by="valid_from desc", + limit=1, ) if not item_price: