From 0d91d3f572df0e0b9b51e39842281e3b19ad9952 Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 26 Sep 2017 10:56:31 +0800 Subject: [PATCH] add schedule_date while creating Material Request --- erpnext/demo/user/purchase.py | 1 + .../production_planning_tool.py | 2 +- erpnext/setup/setup_wizard/sample_data.py | 1 + .../doctype/material_request/test_records.json | 14 +++++++------- erpnext/stock/reorder_item.py | 3 ++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py index 960a3169cf..82983f0a71 100644 --- a/erpnext/demo/user/purchase.py +++ b/erpnext/demo/user/purchase.py @@ -103,6 +103,7 @@ def make_material_request(item_code, qty): mr.material_request_type = "Purchase" mr.transaction_date = frappe.flags.current_date + mr.schedule_date = frappe.utils.add_days(mr.transaction_date, 7) mr.append("items", { "doctype": "Material Request 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 815e504447..99cf6b3560 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -516,7 +516,7 @@ class ProductionPlanningTool(Document): "transaction_date": nowdate(), "status": "Draft", "company": self.company, - "requested_by": frappe.session.user + "schedule_date": add_days(nowdate(), cint(item_wrapper.lead_time_days)), }) material_request.update({"material_request_type": item_wrapper.default_material_request_type}) diff --git a/erpnext/setup/setup_wizard/sample_data.py b/erpnext/setup/setup_wizard/sample_data.py index bc26e09677..43911f06c1 100644 --- a/erpnext/setup/setup_wizard/sample_data.py +++ b/erpnext/setup/setup_wizard/sample_data.py @@ -73,6 +73,7 @@ def make_material_request(items): mr = frappe.get_doc({ "doctype": "Material Request", "material_request_type": "Purchase", + "schedule_date": frappe.utils.add_days(frappe.utils.nowdate(), 7), "items": [{ "schedule_date": frappe.utils.add_days(frappe.utils.nowdate(), 7), "item_code": i.name, diff --git a/erpnext/stock/doctype/material_request/test_records.json b/erpnext/stock/doctype/material_request/test_records.json index f30958a85b..1c714969eb 100644 --- a/erpnext/stock/doctype/material_request/test_records.json +++ b/erpnext/stock/doctype/material_request/test_records.json @@ -2,7 +2,7 @@ { "company": "_Test Company", "doctype": "Material Request", - "fiscal_year": "_Test Fiscal Year 2013", + "fiscal_year": "_Test Fiscal Year 2013", "items": [ { "description": "_Test Item Home Desktop 100", @@ -11,7 +11,7 @@ "item_name": "_Test Item Home Desktop 100", "parentfield": "items", "qty": 54.0, - "schedule_date": "2013-02-26", + "schedule_date": "2013-02-18", "uom": "_Test UOM 1", "warehouse": "_Test Warehouse - _TC" }, @@ -22,7 +22,7 @@ "item_name": "_Test Item Home Desktop 200", "parentfield": "items", "qty": 3.0, - "schedule_date": "2013-02-25", + "schedule_date": "2013-02-19", "uom": "_Test UOM 1", "warehouse": "_Test Warehouse - _TC" } @@ -30,12 +30,12 @@ "material_request_type": "Purchase", "naming_series": "_T-Material Request-", "transaction_date": "2013-02-18", - "schedule_date": "2013-02-25" + "schedule_date": "2013-02-19" }, { "company": "_Test Company", "doctype": "Material Request", - "fiscal_year": "_Test Fiscal Year 2013", + "fiscal_year": "_Test Fiscal Year 2013", "items": [ { "description": "_Test FG Item", @@ -44,7 +44,7 @@ "item_name": "_Test FG Item", "parentfield": "items", "qty": 5, - "schedule_date": "2013-02-25", + "schedule_date": "2013-02-19", "uom": "_Test UOM 1", "warehouse": "_Test Warehouse - _TC" } @@ -52,6 +52,6 @@ "material_request_type": "Manufacture", "naming_series": "_T-Material Request-", "transaction_date": "2013-02-18", - "schedule_date": "2013-02-25" + "schedule_date": "2013-02-19" } ] \ No newline at end of file diff --git a/erpnext/stock/reorder_item.py b/erpnext/stock/reorder_item.py index 01a6a6d547..ade6121700 100644 --- a/erpnext/stock/reorder_item.py +++ b/erpnext/stock/reorder_item.py @@ -121,7 +121,8 @@ def create_material_request(material_requests): mr.update({ "company": company, "transaction_date": nowdate(), - "material_request_type": "Material Transfer" if request_type=="Transfer" else request_type + "material_request_type": "Material Transfer" if request_type=="Transfer" else request_type, + "schedule_date": add_days(nowdate(),cint(item.lead_time_days)) }) for d in items: