Purchase invoice customization

I have marked read only for Rate of item in purchase invoice so the user should change prices in price list as per new cost of purchase. And price is fetched from standard buying.

Now i have some expense purchases for which do not have Item code and we simple and them in item name and make purchase invoice… For them we need to put rate in purchase invoice.

So i want some script to be added that if the item has Item code its rate should work as read only else rate should be amendable.

You can skip Price List Rate and directly enter Basic Rate for an item (if that field is editable).

dear but if we directly keep basic rate editable, than our reason to keep price list rate read only will be lost as we want if cost is changed according standard buying. whole sale and retail is also changed by the user.