[test-fix]
diff --git a/erpnext/patches/v5_0/convert_stock_reconciliation.py b/erpnext/patches/v5_0/convert_stock_reconciliation.py
index 1417426..c4141f1 100644
--- a/erpnext/patches/v5_0/convert_stock_reconciliation.py
+++ b/erpnext/patches/v5_0/convert_stock_reconciliation.py
@@ -4,18 +4,25 @@
# stock reco now amendable
frappe.db.sql("""update tabDocPerm set `amend` = 1 where parent='Stock Reconciliation' and submit = 1""")
+
if frappe.db.has_column("Stock Reconciliation", "reconciliation_json"):
for sr in frappe.db.get_all("Stock Reconciliation", ["name"],
{"reconciliation_json": ["!=", ""]}):
+ start = False
sr = frappe.get_doc("Stock Reconciliation", sr.name)
for item in json.loads(sr.reconciliation_json):
- if item.get("item_code"):
- sr.append("items", {
- "item_code": item.item_code,
- "warehouse": item.warehouse,
- "valuation_rate": item.valuation_rate,
- "qty": item.qty
- })
+ if start:
+ if item.get("item_code"):
+ sr.append("items", {
+ "item_code": item[0],
+ "warehouse": item[1],
+ "valuation_rate": item[3],
+ "qty": item[4]
+ })
+
+ elif item[0]=="Item Code":
+ start = True
+
for item in sr.items:
item.db_update()