fix: item price with party condition (#55100)

(cherry picked from commit 3084e3654c)

# Conflicts:
#	erpnext/stock/doctype/item/test_item.py
#	erpnext/stock/get_item_details.py
This commit is contained in:
Mihir Kandoi
2026-05-20 17:18:15 +05:30
committed by Mergify
parent aa79247c39
commit 0e2de80bc5
3 changed files with 39 additions and 0 deletions

View File

@@ -551,6 +551,7 @@ class TestBatch(FrappeTestCase):
"plc_conversion_rate": 1,
"customer": "_Test Customer",
"name": None,
"qty": 1,
}
)

View File

@@ -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():

View File

@@ -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")