From de6a1577733e3f74200732f6164dbc44149db3e8 Mon Sep 17 00:00:00 2001 From: pandiyan Date: Fri, 10 Jul 2026 11:36:05 +0530 Subject: [PATCH] fix: validate planned end date is not before planned start date in work order Work Order allowed saving with a Planned End Date earlier than the Planned Start Date without any validation. Add a validate_dates check that throws when the planned end date precedes the planned start date. (cherry picked from commit 2ec780cb353b74de25802b9062dca8c8c6956ed) --- erpnext/manufacturing/doctype/work_order/work_order.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index d5f7b1dd976..dd5c07c2945 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -157,6 +157,7 @@ class WorkOrder(Document): self.check_wip_warehouse_skip() self.calculate_operating_cost() self.validate_qty() + self.validate_dates() self.validate_transfer_against() self.validate_operations() self.status = self.get_status() @@ -175,6 +176,11 @@ class WorkOrder(Document): self.validate_operations_sequence() + def validate_dates(self): + if self.planned_start_date and self.planned_end_date: + if get_datetime(self.planned_end_date) < get_datetime(self.planned_start_date): + frappe.throw(_("Planned End Date cannot be before Planned Start Date")) + def validate_operations_sequence(self): if all([not op.sequence_id for op in self.operations]): for op in self.operations: