From 7182d349dfb28b95cbfa00c1a3731554c934ab11 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Mon, 16 Feb 2015 18:47:58 +0530 Subject: [PATCH] fixes for capacity planning using production planning tool --- .../doctype/production_order/production_order.py | 13 ++++++++----- .../production_planning_tool.py | 5 ++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 7375cf229e..3e9b710fd4 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -222,11 +222,14 @@ class ProductionOrder(Document): 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 24204f254a..47b3ccbfa4 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 @@ class ProductionPlanningTool(Document): 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: