From 4ad8e55d067f25da225dc3e7ac4ed60615ea96b1 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 4 Dec 2025 22:03:54 +0530 Subject: [PATCH] fix: SRE for manufacture entry for job card --- .../doctype/work_order/work_order.py | 26 ++++++++++++++++++- .../stock/doctype/stock_entry/stock_entry.py | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index fa16ca6e6b1..71bd94ad73a 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -1747,7 +1747,10 @@ class WorkOrder(Document): stock_entry.reload() if stock_entry.purpose == "Manufacture" and ( - self.sales_order or self.production_plan_sub_assembly_item or self.subcontracting_inward_order + self.sales_order + or self.production_plan_sub_assembly_item + or self.subcontracting_inward_order + or stock_entry.job_card ): items = self.get_finished_goods_for_reservation(stock_entry) elif stock_entry.purpose == "Material Transfer for Manufacture": @@ -1794,6 +1797,27 @@ class WorkOrder(Document): item_details = self.get_wo_details() elif self.subcontracting_inward_order: item_details = self.get_scio_details() + elif stock_entry.job_card: + # Reserve the final product for the job card. + finished_good = frappe.db.get_value("Job Card", stock_entry.job_card, "finished_good") + + for row in stock_entry.items: + if row.item_code == finished_good: + item_details = [ + frappe._dict( + { + "item_code": row.item_code, + "stock_qty": row.qty, + "stock_reserved_qty": 0, + "warehouse": row.t_warehouse, + "voucher_no": stock_entry.work_order, + "voucher_type": "Work Order", + "name": row.name, + "delivered_qty": 0, + } + ) + ] + break else: # Reserve the final product for the sales order. item_details = self.get_so_details() diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 67016b81f3e..dbca583e29d 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -1953,6 +1953,7 @@ class StockEntry(StockController, SubcontractingInwardController): if ( self.purpose == "Manufacture" and not pro_doc.sales_order + and not self.job_card and not pro_doc.production_plan_sub_assembly_item and not pro_doc.subcontracting_inward_order ):