Fetch Custom Field on get item from option

Hello everyone,

I want to add some custom field on select of “Get Items from” option. Example in sales invoice we have option from get items from sales order. On selecting of a sales order i want to fetch one/two field value from sales order master. I need to do this by custom script.

TIA

You can use “Depends On”, if the condition is TRUE, then it’ll be showed up.

You didn’t understand my requirements

@munim

Give the same name to custom fields on both form Sales Order and Sales Invoice.
If it’s not worked. you have to override make_sales_invoice method from sales_order.py with custom method. Map your custom fields in that method.

doclist = get_mapped_doc("Sales Order", source_name, {
		"Sales Order": {
			"doctype": "Sales Invoice",
			"field_map": {
				"party_account_currency": "party_account_currency",
                                #map your custom fields here
			},
			"validation": {
				"docstatus": ["=", 1]
			}
		},

add following lines to your hooks to override method.

override_whitelisted_methods = {
 	"erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice": "your custom method path"
}

@Sangram I have tried but when fetch sales order, it shows

" You do not have enough permissions to access this resource. Please contact your manager to get access."

NB: I am logged in with administrator account.

I have whitelisted the method by @frappe.whitelist() in my custom app. After that an error showing that “job_number_test() takes exactly 2 arguments (0 given)”

My code is
@frappe.whitelist()
def job_number_test(doc,method):

doclist = get_mapped_doc("Sales Order", source_name, {
    "Sales Order": {
        "doctype": "Sales Invoice",
        "field_map": {
            "party_account_currency": "party_account_currency",
            "munim" : "munim1"
        }
    }
}

)
In hooks
override_whitelisted_methods = {
“erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice”:
“erpnext_shipping.manage_shipping.sales_invoice_custom.job_number_test”
}