[solved] Cannot create a new warehouse - must frappe.db.commit()

I have tried creating a new warehouse via the API, the response is 200 but if i refresh my warehouse list the new entry is not there. I have tried both methods both of them produce the same results

@frappe.whitelist()
def createFeedsWarehouse(company):
#Create New Warehouse
doc = frappe.get_doc({
“doctype”: “Warehouse”,
“warehouse_name”: “Feeds”,
“company”: company,
“is_group”:0
})

try:
doc.insert()
return doc.name
except Exception as err:
return err

@frappe.whitelist()
def createFeedsWarehouse(company):
#Create FeedsWarehouse
doc = frappe.new_doc(“Warehouse”)
doc.warehouse_name = “Feeds”
doc.company = company
doc.is_group = 0
try:
doc.insert()
return doc.name
except Exception as err:
return err

Hi,
After doc.insert() you have to do frappe.db.commit()
Thanks

@Ranjith thanks a million, i wish there was a way to reward you on this discuss forum

@Ranjith Thanks! Had the same problem. Without frappe.db.commit() the doc inserted only if executed from terminal bench execute and not from http api/method.