mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-27 15:12:21 +01:00
perf: Get bin details only for stock items
This commit is contained in:
@@ -104,22 +104,8 @@ def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=Tru
|
|||||||
if args.customer and cint(args.is_pos):
|
if args.customer and cint(args.is_pos):
|
||||||
out.update(get_pos_profile_item_details(args.company, args, update_data=True))
|
out.update(get_pos_profile_item_details(args.company, args, update_data=True))
|
||||||
|
|
||||||
if (
|
if item.is_stock_item:
|
||||||
args.get("doctype") == "Material Request"
|
update_bin_details(args, out, doc)
|
||||||
and args.get("material_request_type") == "Material Transfer"
|
|
||||||
):
|
|
||||||
out.update(get_bin_details(args.item_code, args.get("from_warehouse")))
|
|
||||||
|
|
||||||
elif out.get("warehouse"):
|
|
||||||
if doc and doc.get("doctype") == "Purchase Order":
|
|
||||||
# calculate company_total_stock only for po
|
|
||||||
bin_details = get_bin_details(
|
|
||||||
args.item_code, out.warehouse, args.company, include_child_warehouses=True
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
bin_details = get_bin_details(args.item_code, out.warehouse, include_child_warehouses=True)
|
|
||||||
|
|
||||||
out.update(bin_details)
|
|
||||||
|
|
||||||
# update args with out, if key or value not exists
|
# update args with out, if key or value not exists
|
||||||
for key, value in out.items():
|
for key, value in out.items():
|
||||||
@@ -202,6 +188,24 @@ def set_valuation_rate(out, args):
|
|||||||
out.update(get_valuation_rate(args.item_code, args.company, out.get("warehouse")))
|
out.update(get_valuation_rate(args.item_code, args.company, out.get("warehouse")))
|
||||||
|
|
||||||
|
|
||||||
|
def update_bin_details(args, out, doc):
|
||||||
|
if (
|
||||||
|
args.get("doctype") == "Material Request"
|
||||||
|
and args.get("material_request_type") == "Material Transfer"
|
||||||
|
):
|
||||||
|
out.update(get_bin_details(args.item_code, args.get("from_warehouse")))
|
||||||
|
|
||||||
|
elif out.get("warehouse"):
|
||||||
|
company = args.company if (doc and doc.get("doctype") == "Purchase Order") else None
|
||||||
|
|
||||||
|
# calculate company_total_stock only for po
|
||||||
|
bin_details = get_bin_details(
|
||||||
|
args.item_code, out.warehouse, company, include_child_warehouses=True
|
||||||
|
)
|
||||||
|
|
||||||
|
out.update(bin_details)
|
||||||
|
|
||||||
|
|
||||||
def process_args(args):
|
def process_args(args):
|
||||||
if isinstance(args, str):
|
if isinstance(args, str):
|
||||||
args = json.loads(args)
|
args = json.loads(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user