Utility: reset serial no status and warehouse

This commit is contained in:
nabinhait 2014-07-14 11:43:00 +05:30
parent 614fb750b7
commit 5c38488590

View File

@ -190,3 +190,18 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin
"posting_date": posting_date,
"posting_time": posting_time
})
def reset_serial_no_status_and_warehouse(serial_nos=[]):
if not serial_nos:
serial_nos = frappe.db.sql_list("""select name from `tabSerial No` where status != 'Not in Use'
and docstatus = 0""")
for serial_no in serial_nos:
try:
sr = frappe.get_doc("Serial No", serial_no)
sr.via_stock_ledger = True
sr.save()
except:
pass
frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""")