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() {
					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"]],
						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


Any idea where I could be going wrong?

Does anyone know if there is a solution to this?

In the version 14 , you can create stock entry directly from the purchase receipt.

Thanks but that option in v14 doesn’t quite work as needed.

I tried, but if a Purchase Receipt line contains rejected items (with no accepted items) then you are blocked from creating a stock entry from a Purchase Receipt.

Can anyone suggest a way to add Get Items from…a Purchase Receipt as an option?

The current option for making a Stock Entry from the Purchase Receipt only works if there are a no rejected items.


Purchase Receipts should generate stock entries to insert stock into warehouses. The entire system fails because this is not happening. Surely, I am missing something fundamental?


My use case is using the Purchase Receipt as a method to easily find items that were delivered together, instead or trying to find delivered items individually, so they can be transferred from one warehouse to another.

I want to be able to generate a Stock Transfer of items that have arrived and been assigned Lot Numbers, which someone else checks and can remove items from the Transfer which do not pass the check.

Reason? The way some items in an order are processed. To explain…

  • Some items in an order may require an inspection for specific characteristics (not broken/damaged losses), others can be generic/consumables that require no inspection.

  • The inspection is performed using the Quality Inspection as part of the Purchase Receipt process.

  • The Purchase Receipt is submitted, which generates Lot Numbers for the inspected items.

  • These items are on hold until the inspection is checked and confirmed by another user.

  • If the checks fail, they are then transferred to a Holding area, until the issue for fail is resolved (commonly failure of the supplier to provide/incorrect Certificate of Analysis or Certificate or Conformity) or the items are returned to the supplier due to not meeting requirements.

As it stands I cannot use Purchase Receipt as a method to control these checks.
I need to submit the Purchase Receipt to generate the Lot Numbers for the items. If I was to add a workflow to add a second inspection step then the Cancel option would cancel the whole Purchase Receipt, so all items would be cancelled with lot numbers cancelled for all items.
i.e. if you had 10 items and 1 failed, I would have to cancel/amend the Purchase Receipt and generate 10 new Lot Numbers for all items, even though only 1 failed.

My solution was to create a “Pending Checks” warehouse to hold these items. Generate a Stock Entry by using the Purchase Receipt to populate the Entry, and get a second user to check and approve or remove any items that did not pass.

Hope this explains things better?

Turns out if you go into the Purchase Receipt there is a blue Create button and inside you can click Make Stock Entry and that seems to be sufficient for my usecase. You need to set a staging receiving warehouse for this to work as items cannot be transferred to the same warehouse.

Would love to know why this is not automated. Must be because the integration with “inspections” is not implemented yet. That would be my guess.

Already tried that and it only works if all items are accepted, if you have a rejected item on it it throws an error message.

It seems odd that you can create a Stock Entry from a Purchase Receipt, but you cannot create a Stock Entry and use a Purchase Receipt to populate the items.

Will try and work on it and see if I can come up with something

This is easily achieved if you customize frappe.

Create a client script that does the magic if a stock entry sets a Purchase Receipt. Turns out the stock_entry doctype already as link field to a “Purchase Receipt” called purchase_reciept_no. It is not visible and only visible if the purpose field is set to “Purchase Return”. This field can only be set from code.

Not sure if things looking at stock_entries can find what they are looking for when those fields are set.

Thanks, I will have a look at that. I had looked at the purchase_invoice.js code previously.