repost stock reconciliation
This commit is contained in:
parent
ee2bc92ab2
commit
3f4885e342
31
erpnext/patches/v4_2/repost_stock_reconciliation.py
Normal file
31
erpnext/patches/v4_2/repost_stock_reconciliation.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import json
|
||||
|
||||
def execute():
|
||||
existing_allow_negative_stock = frappe.db.get_default("allow_negative_stock")
|
||||
frappe.db.set_default("allow_negative_stock", 1)
|
||||
|
||||
head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]
|
||||
stock_reco_to_be_reposted = []
|
||||
for d in frappe.db.sql("""select name, reconciliation_json from `tabStock Reconciliation`
|
||||
where docstatus=1 and creation > '2014-03-01'""", as_dict=1):
|
||||
data = json.loads(d.reconciliation_json)
|
||||
for row in data[data.index(head_row)+1:]:
|
||||
if row[3] in ["", None]:
|
||||
stock_reco_to_be_reposted.append(d.name)
|
||||
break
|
||||
|
||||
for dn in stock_reco_to_be_reposted:
|
||||
reco = frappe.get_doc("Stock Reconciliation", dn)
|
||||
reco.docstatus = 2
|
||||
reco.on_cancel()
|
||||
|
||||
reco.docstatus = 1
|
||||
reco.validate()
|
||||
reco.on_submit()
|
||||
|
||||
frappe.db.set_default("allow_negative_stock", existing_allow_negative_stock)
|
Loading…
x
Reference in New Issue
Block a user