From b6ca708d9fda969e399bb4c38708b1737a41224d Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 11 Aug 2026 12:38:59 +0530 Subject: [PATCH] fix: reinstate mandatory manufactured qty check for manufacture entries --- .../doctype/stock_entry/services/manufacturing.py | 14 ++++++++++++++ erpnext/stock/doctype/stock_entry/stock_entry.py | 1 + 2 files changed, 15 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/services/manufacturing.py b/erpnext/stock/doctype/stock_entry/services/manufacturing.py index 3b0eef171fe..8a5555bf391 100644 --- a/erpnext/stock/doctype/stock_entry/services/manufacturing.py +++ b/erpnext/stock/doctype/stock_entry/services/manufacturing.py @@ -25,6 +25,10 @@ class DuplicateEntryForWorkOrderError(frappe.ValidationError): pass +class ManufacturedQtyMandatoryError(frappe.ValidationError): + pass + + class OperationsNotCompleteError(frappe.ValidationError): pass @@ -282,6 +286,7 @@ class ManufactureStockEntry(BaseManufactureStockEntry): def validate(self): self.validate_warehouse() self.validate_raw_materials_exists() + self.validate_manufactured_qty() self.check_if_operations_completed() self.check_duplicate_entry_for_work_order() self.validate_component_and_quantities() @@ -391,6 +396,14 @@ class ManufactureStockEntry(BaseManufactureStockEntry): if not self.doc.work_order: frappe.throw(_("Work Order is mandatory")) + def validate_manufactured_qty(self): + """Without fg_completed_qty, submit never updates or validates the work order's produced qty.""" + if not self.wo_doc or self.wo_doc.track_semi_finished_goods: + return + + if not self.doc.fg_completed_qty: + frappe.throw(_("For Quantity (Manufactured Qty) is mandatory"), ManufacturedQtyMandatoryError) + def check_if_operations_completed(self): """Require operation (job card) completion before manufacture, so operating costs are captured.""" if not self.wo_doc or self.wo_doc.track_semi_finished_goods: @@ -950,6 +963,7 @@ class MaterialConsumptionForManufactureStockEntry(ManufactureStockEntry): def validate(self): self.validate_work_order() + self.validate_manufactured_qty() self.check_if_operations_completed() def add_items(self): diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 13ae8e66aae..b26c004237a 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -39,6 +39,7 @@ from erpnext.stock.utils import get_incoming_rate from .services.disassemble import DisassembleStockEntry from .services.manufacturing import ( DuplicateEntryForWorkOrderError, + ManufacturedQtyMandatoryError, ManufactureStockEntry, MaterialConsumptionForManufactureStockEntry, OperationsNotCompleteError,