brotherton-erpnext/erpnext/patches/v13_0/update_reserved_qty_closed_wo.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
597 B
Python
Raw Normal View History

2022-02-09 06:08:52 +00:00
import frappe
from erpnext.stock.utils import get_bin
def execute():
wo = frappe.qb.DocType("Work Order")
wo_item = frappe.qb.DocType("Work Order Item")
incorrect_item_wh = (
frappe.qb.from_(wo)
.join(wo_item)
.on(wo.name == wo_item.parent)
.select(wo_item.item_code, wo.source_warehouse)
.distinct()
.where((wo.status == "Closed") & (wo.docstatus == 1) & (wo.source_warehouse.notnull()))
).run()
for item_code, warehouse in incorrect_item_wh:
if not (item_code and warehouse):
continue
bin = get_bin(item_code, warehouse)
bin.update_reserved_qty_for_production()