Multi-Currency PO created from SO

A Sales Order is in my customer’s currency, and from that I create a Purchase Order in my company’s currency. All price lists are set up correctly, and everything works!

But, the Sales Order currency is copied into the Purchase Order, so by default is incorrect. I can manually edit the PO, change the currency, and all values update correctly, amazingly good.

A perfect solution would automatically populate the PO currency from the buying_price_list. So, I wrote a server script for that:
DocType Event / Purchase Order / Before Insert

doc.currency = frappe.get_doc(‘Price List’, doc.buying_price_list).currency

Nice. But, the new currency does not automatically flow through the item table. I still must edit and save the PO. So, what “before insert” server script will update the item table to reflect the the new currency? As a wild guess, I tried:


but, errors due to NoneType has no methods.

It a bug! Reported, with fix GitHub Issue 25498