@frappe.whitelist()
def cancel(doctype=None, name=None, workflow_state_fieldname=None, workflow_state=None):
 try:
  doc = frappe.get_doc(doctype, name)
  if (workflow_state_fieldname and workflow_state):
   doc.set(workflow_state_fieldname, workflow_state)
  doc.cancel()
  send_updated_docs(doc)
 except Exception:
  frappe.errprint(frappe.utils.get_traceback())
  frappe.msgprint(frappe._(u'Did not cancel'))
  raise

@ frappe . whitelist ( ) def cancel ( doctype = None , name = None , workflow_state_fieldname = None , workflow_state = None ) : try : doc = frappe . get_doc ( doctype , name ) if ( workflow_state_fieldname and workflow_state ) : doc . set ( workflow_state_fieldname , workflow_state ) doc . cancel ( ) send_updated_docs ( doc ) except Exception : frappe . errprint ( frappe . utils . get_traceback ( ) ) frappe . msgprint ( frappe . _ ( u'Did not cancel' ) ) raise
cancel a document .