"Get Items From" Function in Stock Entry

Is there a way to have the “Get Items From” function in stock entry to pull Item Codes from Quotation? Thanks!

Can you please explain the use case, why would you want to pull items from Quotation to Stock Entry?

We are consigning stocks to different depots and I designated them to different Warehouses in ERPNext. I’m doing Material Transfers everytime i release stock from my Main warehouse. The depots need the selling price of each item released from my warehouse. So in order to ease item entry in Stock Entry, I would like to fetch item code and quantity from Quotation. Quotation would serve as my price list and quantity document for the depot.

I’m also open to any suggestions. Thanks!

Hi

Just to give an Idea.

You have to add a script like this in your stock_entry.js . this script handles the button to pull data from Quotation

if (this.frm.doc.docstatus===0) {
	cur_frm.add_custom_button(__('From Quotation'),
		function() {
			frappe.model.map_current_doc({
				method: "erpnext.selling.doctype.quotation.quotation.make_stock_entry",
				source_doctype: "Quotation",
				get_query_filters: {
					docstatus: 1,
					status: ["!=", "Lost"],
					order_type: cur_frm.doc.order_type,
					customer: cur_frm.doc.customer || undefined,
					company: cur_frm.doc.company
				}
			})
		});
}

Now you need something like this on your quotation.py

def make_stock_entry(source_name, target_doc=None):
	return _make_sales_order(source_name, target_doc)

def _make_stock_entry(source_name, target_doc=None, ignore_permissions=False):
	customer = _make_customer(source_name, ignore_permissions)

	doclist = get_mapped_doc("Quotation", source_name, {
			"Quotation": {
				"doctype": "Stock Entry",
				"validation": {
					"docstatus": ["=", 1]
				}
			},
			"Quotation Item": {
				"doctype": "Stock Entry Item",
				"field_map": [
					["name", "prevdoc_detail_docname"],
					["parent", "prevdoc_docname"],
					["parenttype", "prevdoc_doctype"],
					["uom", "stock_uom"],
					["uom", "uom"]
				]
			},
		}, target_doc, ignore_permissions=ignore_permissions)

	# postprocess: fetch shipping address, set missing values

	return doclist

did not test this codes but ive done this on Purchase Receipt to Delivery Note
this is just to give an idea.

@claily
Thank you for this code. Just wondering if i add this code and i update erpnext. Would it remove my custom code?

yes or it will ask you to commit the changes before updating

you have to git stash it
then update

Could there be a workaround for a Custom Script instead of adding code?