@frappe.whitelist()
def savedocs(doc, action):
 try:
  doc = frappe.get_doc(json.loads(doc))
  set_local_name(doc)
  doc.docstatus = {u'Save': 0, u'Submit': 1, u'Update': 1, u'Cancel': 2}[action]
  if (doc.docstatus == 1):
   doc.submit()
  else:
   try:
    doc.save()
   except frappe.NameError as e:
    (doctype, name, original_exception) = (e if isinstance(e, tuple) else ((doc.doctype or u''), (doc.name or u''), None))
    frappe.msgprint(frappe._(u'{0} {1} already exists').format(doctype, name))
    raise
  run_onload(doc)
  frappe.get_user().update_recent(doc.doctype, doc.name)
  send_updated_docs(doc)
 except Exception:
  if (not frappe.local.message_log):
   frappe.msgprint(frappe._(u'Did not save'))
  frappe.errprint(frappe.utils.get_traceback())
  raise

@ frappe . whitelist ( ) def savedocs ( doc , action ) : try : doc = frappe . get_doc ( json . loads ( doc ) ) set_local_name ( doc ) doc . docstatus = { u'Save' : 0 , u'Submit' : 1 , u'Update' : 1 , u'Cancel' : 2 } [ action ] if ( doc . docstatus == 1 ) : doc . submit ( ) else : try : doc . save ( ) except frappe . NameError as e : ( doctype , name , original_exception ) = ( e if isinstance ( e , tuple ) else ( ( doc . doctype or u'' ) , ( doc . name or u'' ) , None ) ) frappe . msgprint ( frappe . _ ( u'{0} {1} already exists' ) . format ( doctype , name ) ) raise run_onload ( doc ) frappe . get_user ( ) . update_recent ( doc . doctype , doc . name ) send_updated_docs ( doc ) except Exception : if ( not frappe . local . message_log ) : frappe . msgprint ( frappe . _ ( u'Did not save' ) ) frappe . errprint ( frappe . utils . get_traceback ( ) ) raise
save / submit / update doclist .