brotherton-erpnext/erpnext/patches/v5_0/convert_stock_reconciliation.py

29 lines
732 B
Python
Raw Normal View History

2015-02-20 09:41:56 +00:00
import frappe, json
def execute():
# stock reco now amendable
frappe.db.sql("""update tabDocPerm set `amend` = 1 where parent='Stock Reconciliation' and submit = 1""")
2015-03-20 10:07:31 +00:00
2015-02-20 09:41:56 +00:00
if frappe.db.has_column("Stock Reconciliation", "reconciliation_json"):
for sr in frappe.db.get_all("Stock Reconciliation", ["name"],
{"reconciliation_json": ["!=", ""]}):
2015-03-20 10:07:31 +00:00
start = False
2015-02-20 09:41:56 +00:00
sr = frappe.get_doc("Stock Reconciliation", sr.name)
for item in json.loads(sr.reconciliation_json):
2015-03-20 10:07:31 +00:00
if start:
2015-03-20 10:22:11 +00:00
sr.append("items", {
"item_code": item[0],
"warehouse": item[1],
"valuation_rate": item[3],
"qty": item[4]
})
2015-03-20 10:07:31 +00:00
elif item[0]=="Item Code":
start = True
2015-02-20 09:41:56 +00:00
for item in sr.items:
item.db_update()