I make custom api and it has a parameter looks like this:
"obj": {
"doc": {
"owner": "Administrator",
"docstatus": 0,
"idx": 0,
"period_start_date": "2024-07-17 21:08:15",
"period_end_date": "2024-07-17 22:46:05.271028",
"posting_date": "2024-07-17",
"posting_time": "22:46:05.270879",
"pos_opening_entry": "POS-OPE-2024-00001",
"status": "Draft",
"company": "Ekasa Multi Semesta",
"pos_profile": "Outlet Utama",
"user": "Administrator",
"grand_total": 5000.0,
"net_total": 5000.0,
"total_quantity": 1.0,
"doctype": "POS Closing Entry",
"taxes": [],
"payment_reconciliation": [
{
"docstatus": 0,
"idx": 1,
"mode_of_payment": "Cash",
"opening_amount": 0.0,
"expected_amount": 5000.0,
"closing_amount": 0.0,
"difference": 0.0,
"parentfield": "payment_reconciliation",
"parenttype": "POS Closing Entry",
"doctype": "POS Closing Entry Detail",
"__islocal": 1
},
{
"docstatus": 0,
"idx": 2,
"mode_of_payment": "Bank Transfer",
"opening_amount": 0.0,
"expected_amount": 0.0,
"closing_amount": 0.0,
"difference": 0.0,
"parentfield": "payment_reconciliation",
"parenttype": "POS Closing Entry",
"doctype": "POS Closing Entry Detail",
"__islocal": 1
}
],
"pos_transactions": [
{
"docstatus": 0,
"idx": 1,
"pos_invoice": "ACC-PSINV-2024-00001",
"posting_date": "2024-07-17",
"customer": "NN",
"grand_total": 5000.0,
"is_return": 0,
"parentfield": "pos_transactions",
"parenttype": "POS Closing Entry",
"doctype": "POS Invoice Reference",
"__islocal": 1
}
],
"__islocal": 1,
"__unsaved": 1
}
}
which is obj[“doc”] actually a POS Closing Entry Document.
Inside the API, I do this:
closing_entry = frappe.new_doc("POS Closing Entry")
closing_entry = obj["doc"]
closing_entry.save()
But it gives me an error : “AttributeError: ‘dict’ object has no attribute ‘save’”
I need to make this custom API and cannot just use regular POST endpoint.