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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
934 B
Python
Raw Normal View History

from __future__ import unicode_literals
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-25 09:21:05 +00:00
frappe.reload_doc("stock", "doctype", "stock_reconciliation_item")
frappe.reload_doctype("Stock Reconciliation")
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)
2015-03-23 08:40:38 +00:00
for row 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", {
2015-03-23 08:40:38 +00:00
"item_code": row[0],
"warehouse": row[1],
2015-03-25 09:21:05 +00:00
"qty": row[2] if len(row) > 2 else None,
"valuation_rate": row[3] if len(row) > 3 else None
2015-03-20 10:22:11 +00:00
})
2015-03-20 10:07:31 +00:00
2015-03-23 08:40:38 +00:00
elif row[0]=="Item Code":
2015-03-20 10:07:31 +00:00
start = True
2015-02-20 09:41:56 +00:00
for item in sr.items:
item.db_update()