From 492ee05727420cb5a080d64057f62224498faa37 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 11 Aug 2026 12:33:59 +0530 Subject: [PATCH] fix: honor overproduction allowance in duplicate entry check Compare already-entered finished good qty against the work order qty plus the configured overproduction percentage, mirroring the submit-time guard in work_order/services/status.py, so a save is never rejected that the submission contract would accept. --- .../stock/doctype/stock_entry/services/manufacturing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/services/manufacturing.py b/erpnext/stock/doctype/stock_entry/services/manufacturing.py index 7b66623cb02..3b0eef171fe 100644 --- a/erpnext/stock/doctype/stock_entry/services/manufacturing.py +++ b/erpnext/stock/doctype/stock_entry/services/manufacturing.py @@ -436,7 +436,7 @@ class ManufactureStockEntry(BaseManufactureStockEntry): ) def check_duplicate_entry_for_work_order(self): - """Block another manufacture entry once existing entries already cover the full work order qty.""" + """Block another manufacture entry once existing entries already cover the work order qty plus allowance.""" if not self.wo_doc or self.wo_doc.track_semi_finished_goods: return @@ -453,7 +453,11 @@ class ManufactureStockEntry(BaseManufactureStockEntry): if not other_entries: return - if self.get_fg_qty_already_entered(other_entries) >= flt(self.wo_doc.qty): + allowance_percentage = flt( + frappe.db.get_single_value("Manufacturing Settings", "overproduction_percentage_for_work_order") + ) + allowed_qty = flt(self.wo_doc.qty) + (allowance_percentage / 100 * flt(self.wo_doc.qty)) + if self.get_fg_qty_already_entered(other_entries) >= allowed_qty: frappe.throw( _("Stock Entries already created for Work Order {0}: {1}").format( self.doc.work_order, ", ".join(other_entries)