2019-04-09 11:17:10 +00:00
|
|
|
import frappe
|
|
|
|
|
|
|
|
|
|
|
|
def execute():
|
2019-04-11 09:33:53 +00:00
|
|
|
frappe.reload_doc("stock", "doctype", "batch")
|
|
|
|
|
2019-04-09 11:17:10 +00:00
|
|
|
for batch in frappe.get_all("Batch", fields=["name", "batch_id"]):
|
2020-04-07 11:59:06 +00:00
|
|
|
batch_qty = frappe.db.get_value("Stock Ledger Entry",
|
|
|
|
{"docstatus": 1, "batch_no": batch.batch_id, "is_cancelled": "No"},
|
|
|
|
"sum(actual_qty)") or 0.0
|
2019-04-09 11:17:10 +00:00
|
|
|
frappe.db.set_value("Batch", batch.name, "batch_qty", batch_qty, update_modified=False)
|