Stock Entry - Get Items from Purchase Receipt?

In the Stock Entry drop down I s there a way to add Get the items from a Purchase Receipt?, as only Material Request and Purchase Invoice are available.

My use case is that I want to be able to make a transfer using all items from a Purchase Receipt, as often an order from a supplier may have items outstanding.

I’ve tried adding the following code, taken from the purchase_invoice.js

frappe.ui.form.on('Stock Entry', {
	refresh(frm) {


frm.add_custom_button(__('Purchase Receipt'), function() {
				erpnext.utils.map_current_doc({
					method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
					source_doctype: "Purchase Receipt",
					target: me.frm,
					setters: {
						supplier: me.frm.doc.supplier || undefined,
						posting_date: undefined
					},
					get_query_filters: {
						docstatus: 1,
						status: ["not in", ["Closed", "Completed", "Return Issued"]],
						company: me.frm.doc.company,
						is_return: 0
					}
				});

		// your code here
	}
);
}})
;

Which does bring up the dialog box to select a Purchase Receipt

However, when I select a Purchase Receipt and click Get Items I get the following error:

TypeError: getattr(): attribute name must be string

image

Any idea where I could be going wrong?