If manually select Sales Order then will show quickly but when Click the Get Sales Order Button then does not show but when you save the Production Plan then will be set automatically.
Here’s an example server script that fetches the delivery date from the Sales Order and sets it in the corresponding Production Plan Sales Order row:
from frappe.utils import flt
def set_delivery_date(doc, method):
for row in doc.sales_orders:
sales_order = frappe.get_doc("Sales Order", row.sales_order)
# fetch the delivery date from the Sales Order
delivery_date = sales_order.delivery_date
# set the delivery date in the Production Plan Sales Order row
for item in row.items:
doc_item = doc.get_child_doc("sales_orders", {"sales_order": row.sales_order, "item_code": item.item_code})
doc_item.delivery_date = delivery_date
# save the changes to the Production Plan
doc.save(ignore_permissions=True)
below script should be added to a Python file (e.g., my_module.py) in your custom app’s hooks.py file as follows:
It will run the set_delivery_date function before saving a Production Plan document, which will fetch the delivery date from the linked Sales Order and set it in the corresponding Production Plan Sales Order row.
The first solution should be adequate for our application as we are only using browser for ERPNext.
Now, we are trying to get the delivery dates for each Sales Order Item (child table of Sales Order doctype transferred into the Production Plan Item (child table of Production Plan doctype)