From b4981f8816071eaab346801e60aaf7ea850fa787 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sun, 21 Jan 2024 18:05:20 +0530 Subject: [PATCH] fix: key error during reposting (cherry picked from commit ebc8230d4564385b151e19f21d57172afe803108) --- erpnext/stock/stock_ledger.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index b19a34a354..a221e006af 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -439,7 +439,7 @@ def get_distinct_item_warehouse(args=None, doc=None, reposting_data=None): reposting_data = get_reposting_data(doc.reposting_data_file) if reposting_data and reposting_data.distinct_item_and_warehouse: - return reposting_data.distinct_item_and_warehouse + return parse_distinct_items_and_warehouses(reposting_data.distinct_item_and_warehouse) distinct_item_warehouses = {} @@ -457,6 +457,16 @@ def get_distinct_item_warehouse(args=None, doc=None, reposting_data=None): return distinct_item_warehouses +def parse_distinct_items_and_warehouses(distinct_items_and_warehouses): + new_dict = frappe._dict({}) + + # convert string keys to tuple + for k, v in distinct_items_and_warehouses.items(): + new_dict[frappe.safe_eval(k)] = frappe._dict(v) + + return new_dict + + def get_affected_transactions(doc, reposting_data=None) -> Set[Tuple[str, str]]: if not reposting_data and doc and doc.reposting_data_file: reposting_data = get_reposting_data(doc.reposting_data_file)