mirror of
https://github.com/frappe/erpnext.git
synced 2026-07-13 10:18:47 +00:00
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 2ec780cb35)
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user