PO made via Python code not getting saved

From Python code of a custom document, I created a Purchase Order on button click. Purchase Order is getting made. When I open the list, it is on Draft status. But when I open the PO it changes to Unsaved.

Here are screenshots :

In List -

When Opening -

Here is the code that creates this PO –

def make_purchase_order(tower_id):
	"""Raise PO with current Tower PO as reference"""
	#purchase order
	tower = frappe.db.get_values('Tower PO', {'name' : tower_id}, '*', as_dict=1)[0]
	#tower_po = dict(tower)
	new_po = frappe.new_doc('Purchase Order')
	new_po.supplier = tower.supplier
	new_po.transaction_date = frappe.utils.nowdate()
	new_po.purpose = "Tower IP Fee Payment"
	new_po.taxes_and_charges = 'GST-18%'
	new_po.append('items', {
		'item_code' : '39029',
		'schedule_date' : frappe.utils.nowdate(),
		'rate' : tower.net_amount,
		'tower_po' : tower.name,
		'total_sites' : tower.total_sites,
		'billing_from' : tower.from_date,
		'billing_to' : tower.to_date
	taxes = frappe.db.get_values('Purchase Taxes and Charges', {'parent': new_po.taxes_and_charges}, '*', as_dict=1)
	for tax in taxes:
		new_po.append("taxes", {
			"charge_type": tax.charge_type,
			"account_head": tax.account_head,
			"description": tax.description,
			"rate": tax.rate,
			"cost_center": 'Main - RK',

I think I have not used the insert() correctly. Also, when previously I used

new_po.docstatus = 0

Instead of this (which is my current code)


2 Purchase Orders were being made. How to save PO correctly ?

Seems correct. Any issue?

Yes, as it is evident in the screenshot - in the list it is in Draft but on opening it is in Unsaved. I have made no changes to PO’s JS file.