diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index a96224882ce..67b53f633b1 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -35,6 +35,7 @@ class ProductionOrder(Document): self.validate_sales_order() self.validate_warehouse() self.calculate_operating_cost() + self.validate_delivery_date() from erpnext.utilities.transaction_base import validate_uom_is_integer validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"]) @@ -219,6 +220,13 @@ class ProductionOrder(Document): else: self.actual_start_date = None self.actual_end_date = None + + def validate_delivery_date(self): + if self.planned_start_date and self.expected_delivery_date and getdate(self.expected_delivery_date) < getdate(self.planned_start_date): + frappe.throw(_("Expected Delivery Date cannot be greater than Planned Start Date")) + + if self.planned_end_date and self.expected_delivery_date and getdate(self.expected_delivery_date) < getdate(self.planned_end_date): + frappe.msgprint(_("Production might not be able to finish by the Expected Delivery Date.")) @frappe.whitelist() def get_item_details(item):