How to get Pricelist to adjust based on purchase


There is a customer who has the need to have a selling pricelist which is based on purchase so that when an item is selected in sales invoice the price that gets fetched should be from the last purchase order.

How can we define such a rule?

Did you found a solution?

At that time I did not spend any time trying to find a working solution.

I have not checked if this functionality is available by default in newer version or ERPNext or not.