In Sales order how to get purchase order number

Hi All ,

I have created purchase order through the sales order , the connection is there but i want the purchase order number in sales order how to fetch it.

To do that, you need to first create a custom field in the Sales Order similar to the Purchase Order. Then, write a server script to ensure that when a Purchase Order is created from a Sales Order and the Purchase Order is submitted, the Purchase Order ID is set in the Sales Order.

is it possible to take within the connections purchase order ?

No, You have to follow the setup that I provided. and it’s too easy to develop the server script for that.

Yes @NCP, I understood because already I have created 180 sales order so these order don’t purchase order number so that only i have asked.

If a purchase order isn’t made from a sales order, how can you set. However, if the purchase order is created from the sales order, you can easily configure this using a server script to update the purchase order ID in the sales invoice.

this script is for the purchase order id is configure in sales order right ?

Yes, when you submit the purchase order then id will set in the sales order.

this is working but i want already submitted purchase orders how to fetch the purchase order Id in sales order ?

You have to make a patch and run it for all.

how can I make this

You need to review the patch list in frappe or erpnext and understand how to implement it.

Link: erpnext/erpnext/patches.txt at develop · frappe/erpnext · GitHub

After reviewing, execute the patch.

Alternatively, you can also configure this via a server script. First, add a checkbox field named “Update Purchase Order ID” to the purchase order. Then, set the document event to “After Save (Submitted Document)”. Afterward, select multiple purchase orders (Bulk Edit), click edit, choose “Update Purchase Order ID”, and update. Ensure the “Update Purchase Order ID” field is set to “Allow on Submit”.

Thanks for your updates but in server script bulk update method not working (AFTER SAVE)

Please use “After Save (Submitted Document)” event instead of “After Save”

We tested so it working.

Thanks @NCP this is working fine :slight_smile: