fix: not able to make material request from SO
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 62a5d4e..fe3fa82 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -5,7 +5,7 @@
import frappe
import json
import frappe.utils
-from frappe.utils import cstr, flt, getdate, cint, nowdate, add_days, get_link_to_form
+from frappe.utils import cstr, flt, getdate, cint, nowdate, add_days, get_link_to_form, strip_html
from frappe import _
from six import string_types
from frappe.model.utils import get_fetch_values
@@ -993,15 +993,20 @@
))
for item in raw_materials:
item_doc = frappe.get_cached_doc('Item', item.get('item_code'))
+
schedule_date = add_days(nowdate(), cint(item_doc.lead_time_days))
- material_request.append('items', {
- 'item_code': item.get('item_code'),
- 'qty': item.get('quantity'),
- 'schedule_date': schedule_date,
- 'warehouse': item.get('warehouse'),
- 'sales_order': sales_order,
- 'project': project
+ row = material_request.append('items', {
+ 'item_code': item.get('item_code'),
+ 'qty': item.get('quantity'),
+ 'schedule_date': schedule_date,
+ 'warehouse': item.get('warehouse'),
+ 'sales_order': sales_order,
+ 'project': project
})
+
+ if not (strip_html(item.get("description")) and strip_html(item_doc.description)):
+ row.description = item_doc.item_name or item.get('item_code')
+
material_request.insert()
material_request.flags.ignore_permissions = 1
material_request.run_method("set_missing_values")