add schedule_date while creating Material Request
diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py
index 960a316..82983f0 100644
--- a/erpnext/demo/user/purchase.py
+++ b/erpnext/demo/user/purchase.py
@@ -103,6 +103,7 @@
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 815e504..99cf6b3 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 @@
"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 bc26e09..43911f0 100644
--- a/erpnext/setup/setup_wizard/sample_data.py
+++ b/erpnext/setup/setup_wizard/sample_data.py
@@ -73,6 +73,7 @@
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 f30958a..1c71496 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 01a6a6d..ade6121 100644
--- a/erpnext/stock/reorder_item.py
+++ b/erpnext/stock/reorder_item.py
@@ -121,7 +121,8 @@
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: