Fetch Delivery date in Custom doctype

Custom Doctype : Order Acceptance
Fetch data From : Sales Order (throught ‘Get Item From’ button)
Problem : Not fetch only delivery date in items table

–>Now what i should try to fetch delivery date. (I also link delivery date field with sales order’s delivery date field but date is not fetch.)

Py :

This Method use for fetch data from Sales Order in Order Acceptance

def make_order_acceptance(source_name, target_doc=None, ignore_permissions=False):
	def postprocess(source, target):
		set_missing_values(source, target)
		#Get the advance paid Journal Entries in Sales Invoice Advance

	def set_missing_values(source, target):
		target.flags.ignore_permissions = True
		# set company address
		if target.company_address:
			target.update(get_fetch_values("Order Acceptance", 'company_address', target.company_address))

	def update_item(source, target, source_parent):
		target.amount = flt(source.amount) - flt(source.billed_amt)
		target.base_amount = target.amount * flt(source_parent.conversion_rate)
		target.qty = target.amount / flt(source.rate) if (source.rate and source.billed_amt) else source.qty

		item = frappe.db.get_value("Item", target.item_code, ["item_group", "selling_cost_center"], as_dict=1)
		target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center") \
			or item.selling_cost_center \
			or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")

	doclist = get_mapped_doc("Sales Order", source_name, {
		"Sales Order": {
			"doctype": "Order Acceptance",
			"validation": {
				"docstatus": ["=", 1]
		"Sales Order Item": {
			"doctype": "Order Acceptance Item",
			"field_map": {
				"parent": "sales_order",
			"postprocess": update_item,
			"condition": lambda doc: doc.qty and (doc.base_amount==0 or abs(doc.billed_amt) < abs(doc.amount))
		"Sales Taxes and Charges": {
			"doctype": "Sales Taxes and Charges",
			"add_if_empty": True
		"Sales Team": {
			"doctype": "Sales Team",
			"add_if_empty": True
	}, target_doc, postprocess, ignore_permissions=ignore_permissions)

	return doclist

Please check if delivery date is mentioned for each item or not in Sales Order Item table (i.e. the table where Item particulars are mentioned)

Now in get_mapped_doc, in Sales Order Item's field_map, add this and try creating your document from Sales Order:

	"parent": "sales_order",
    "delivery_date" : "delivery_date"

On the left side of : are the variables from Sales Order Item which are now being mapped to corresponding variables in Order Acceptance Item. So if delivery_date is the correct field name then try this or else, on the replace deliver_date on the right side by the exact name (i.e. variable name not the Label Delivery Date).

1 Like

Thank You @root13F

it works.

1 Like