From 8e881cc7b961834b96e200cca93c498c07450fde Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 10 Oct 2016 14:58:33 +0530 Subject: [PATCH] [Fix] making of production order from material request with sales order, restirct validation validate_production_order_against_so in production order --- .../production_order/production_order.py | 3 +- .../production_planning_tool.py | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 250d6e65a3..8234e2eab7 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -58,7 +58,8 @@ class ProductionOrder(Document): if so[0].project: self.project = so[0].project - self.validate_production_order_against_so() + if not self.material_request: + self.validate_production_order_against_so() else: frappe.throw(_("Sales Order {0} is not valid").format(self.sales_order)) 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 5fbcf1eb90..1e6c48aed7 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -454,20 +454,21 @@ class ProductionPlanningTool(Document): material_request.update({"material_request_type": item_wrapper.default_material_request_type}) for sales_order, requested_qty in items_to_be_requested[item].items(): - material_request.append("items", { - "doctype": "Material Request Item", - "__islocal": 1, - "item_code": item, - "item_name": item_wrapper.item_name, - "description": item_wrapper.description, - "uom": item_wrapper.stock_uom, - "item_group": item_wrapper.item_group, - "brand": item_wrapper.brand, - "qty": requested_qty, - "schedule_date": add_days(nowdate(), cint(item_wrapper.lead_time_days)), - "warehouse": self.purchase_request_for_warehouse, - "sales_order": sales_order if sales_order!="No Sales Order" else None - }) + if sales_order != 'No Sales Order': + material_request.append("items", { + "doctype": "Material Request Item", + "__islocal": 1, + "item_code": item, + "item_name": item_wrapper.item_name, + "description": item_wrapper.description, + "uom": item_wrapper.stock_uom, + "item_group": item_wrapper.item_group, + "brand": item_wrapper.brand, + "qty": requested_qty, + "schedule_date": add_days(nowdate(), cint(item_wrapper.lead_time_days)), + "warehouse": self.purchase_request_for_warehouse, + "sales_order": sales_order if sales_order!="No Sales Order" else None + }) material_request.flags.ignore_permissions = 1 material_request.submit()