From d97c96d3dedfe7108c7b15be8d6fd0fee63ee79a Mon Sep 17 00:00:00 2001 From: ljain112 Date: Thu, 29 Aug 2024 18:39:05 +0530 Subject: [PATCH 1/3] fix: adjust price insertion logic for internal suppliers/customers --- erpnext/stock/get_item_details.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index e177cd7bbb81..7b73ba1a7a84 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -820,10 +820,11 @@ def get_price_list_rate(args, item_doc, out=None): if price_list_rate is None or frappe.db.get_single_value( "Stock Settings", "update_existing_price_list_rate" ): - if args.get("is_internal_supplier") or args.get("is_internal_customer"): - return out - - if args.price_list and args.rate: + if ( + args.price_list + and args.rate + and not (args.get("is_internal_supplier") or args.get("is_internal_customer")) + ): insert_item_price(args) if not price_list_rate: From 60f2352ae896341172cfb96ca9bbe41eb7e1204b Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 29 Aug 2024 19:35:30 +0530 Subject: [PATCH 2/3] refactor: correct indentation, specify conditions within function --- erpnext/stock/get_item_details.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 7b73ba1a7a84..4df8b19cb99e 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -820,15 +820,10 @@ def get_price_list_rate(args, item_doc, out=None): if price_list_rate is None or frappe.db.get_single_value( "Stock Settings", "update_existing_price_list_rate" ): - if ( - args.price_list - and args.rate - and not (args.get("is_internal_supplier") or args.get("is_internal_customer")) - ): - insert_item_price(args) + insert_item_price(args) - if not price_list_rate: - return out + if price_list_rate is None: + return out out.price_list_rate = flt(price_list_rate) * flt(args.plc_conversion_rate) / flt(args.conversion_rate) @@ -849,6 +844,14 @@ def get_price_list_rate(args, item_doc, out=None): def insert_item_price(args): """Insert Item Price if Price List and Price List Rate are specified and currency is the same""" + if ( + not args.price_list_rate + or not args.rate + or args.get("is_internal_supplier") + or args.get("is_internal_customer") + ): + return + if frappe.db.get_value("Price List", args.price_list, "currency", cache=True) == args.currency and cint( frappe.db.get_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing") ): From b177c4bd82f11c12fca1a8fe575c4694545dd3da Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 3 Sep 2024 11:21:08 +0530 Subject: [PATCH 3/3] fix: typo --- erpnext/stock/get_item_details.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 4df8b19cb99e..4e4f088f502f 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -845,7 +845,7 @@ def get_price_list_rate(args, item_doc, out=None): def insert_item_price(args): """Insert Item Price if Price List and Price List Rate are specified and currency is the same""" if ( - not args.price_list_rate + not args.price_list or not args.rate or args.get("is_internal_supplier") or args.get("is_internal_customer")