2019-04-09 16:47:10 +05:30
|
|
|
import frappe
|
|
|
|
|
|
|
|
|
|
|
|
def execute():
|
2019-04-11 15:03:53 +05:30
|
|
|
frappe.reload_doc("stock", "doctype", "batch")
|
|
|
|
|
2019-04-09 16:47:10 +05:30
|
|
|
for batch in frappe.get_all("Batch", fields=["name", "batch_id"]):
|
2020-04-07 17:29:06 +05:30
|
|
|
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 16:47:10 +05:30
|
|
|
frappe.db.set_value("Batch", batch.name, "batch_qty", batch_qty, update_modified=False)
|