diff --git a/erpnext/stock/doctype/batch/test_batch.py b/erpnext/stock/doctype/batch/test_batch.py index c3764138a08..3a3a49eece4 100644 --- a/erpnext/stock/doctype/batch/test_batch.py +++ b/erpnext/stock/doctype/batch/test_batch.py @@ -551,6 +551,7 @@ class TestBatch(FrappeTestCase): "plc_conversion_rate": 1, "customer": "_Test Customer", "name": None, + "qty": 1, } ) diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index d5f13e62a5c..f385c984d9d 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -136,6 +136,7 @@ class TestItem(FrappeTestCase): currency = frappe.get_cached_value("Company", company, "default_currency") details = get_item_details( +<<<<<<< HEAD { "item_code": "_Test Item", "company": company, @@ -151,6 +152,26 @@ class TestItem(FrappeTestCase): "price_list_uom_dependant": 1, "ignore_pricing_rule": 1, } +======= + ItemDetailsCtx( + { + "item_code": "_Test Item", + "company": company, + "price_list": "_Test Price List", + "currency": currency, + "doctype": "Sales Order", + "conversion_rate": 1, + "price_list_currency": currency, + "plc_conversion_rate": 1, + "order_type": "Sales", + "customer": "_Test Customer", + "conversion_factor": 1, + "price_list_uom_dependant": 1, + "ignore_pricing_rule": 1, + "qty": 1, + } + ) +>>>>>>> 3084e3654c (fix: item price with party condition (#55100)) ) for key, value in to_check.items(): diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 8c205a10874..0ba51e6bb4d 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -1110,10 +1110,23 @@ def get_item_price(args, item_code, ignore_party=False, force_batch_no=False) -> query = query.where(IfNull(ip.batch_no, "").isin(["", args.get("batch_no")])) if not ignore_party: +<<<<<<< HEAD if args.get("customer"): query = query.where(ip.customer == args.get("customer")) elif args.get("supplier"): query = query.where(ip.supplier == args.get("supplier")) +======= + if pctx.customer: + query = query.where( + (ip.customer == pctx.customer) + | ((IfNull(ip.customer, "") == "") & (IfNull(ip.supplier, "") == "")) + ).orderby(IfNull(ip.customer, ""), order=frappe.qb.desc) + elif pctx.supplier: + query = query.where( + (ip.supplier == pctx.supplier) + | ((IfNull(ip.customer, "") == "") & (IfNull(ip.supplier, "") == "")) + ).orderby(IfNull(ip.supplier, ""), order=frappe.qb.desc) +>>>>>>> 3084e3654c (fix: item price with party condition (#55100)) else: query = query.where((IfNull(ip.customer, "") == "") & (IfNull(ip.supplier, "") == "")) @@ -1172,12 +1185,16 @@ def get_price_list_rate_for(args, item_code): if desired_qty and check_packing_list(price_list_rate[0][0], desired_qty, item_code): item_price_data = price_list_rate else: +<<<<<<< HEAD for field in ["customer", "supplier"]: del item_price_args[field] general_price_list_rate = get_item_price( item_price_args, item_code, ignore_party=args.get("ignore_party") ) +======= + general_price_list_rate = get_item_price(pctx, item_code, ignore_party=ctx.get("ignore_party")) +>>>>>>> 3084e3654c (fix: item price with party condition (#55100)) if not general_price_list_rate and args.get("uom") != args.get("stock_uom"): item_price_args["uom"] = args.get("stock_uom")