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],
|
2015-03-20 10:36:34 +00:00
|
|
|
"qty": item[3] if len(item) > 2 else None,
|
|
|
|
"valuation_rate": item[4] if len(item) > 3 else None
|
2015-03-20 10:22:11 +00:00
|
|
|
})
|
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()
|
|
|
|
|