fixes for capacity planning using production planning tool
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 7375cf2..3e9b710 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -222,11 +222,14 @@
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."))
+ if self.docstatus==1:
+ 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):
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index 24204f2..47b3ccb 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
-from frappe.utils import cstr, flt, cint, nowdate, add_days, comma_and
+from frappe.utils import cstr, flt, cint, nowdate, now, add_days, comma_and
from frappe import msgprint, _
@@ -218,6 +218,9 @@
for key in items:
pro = frappe.new_doc("Production Order")
pro.update(items[key])
+
+ pro.planned_start_date = now()
+ pro.set_production_order_operations()
frappe.flags.mute_messages = True
try: