def savedocs(doc, action): """save / submit / update doclist""" try: doc = frappe.get_doc(json.loads(doc)) set_local_name(doc) # action doc.docstatus = { "Save": 0, "Submit": 1, "Update": 1, "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 "", doc.name or "", None) frappe.msgprint( frappe._("{0} {1} already exists").format(doctype, name)) raise # update recent documents 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._('Did not save')) frappe.errprint(frappe.utils.get_traceback()) raise
def savedocs(): """save / submit / update doclist""" try: doc = frappe.get_doc(json.loads(frappe.form_dict.doc)) set_local_name(doc) # action doc.docstatus = { "Save": 0, "Submit": 1, "Update": 1, "Cancel": 2 }[frappe.form_dict.action] try: doc.save() except frappe.NameError, e: doctype, name, original_exception = e if isinstance( e, tuple) else (doc.doctype or "", doc.name or "", None) frappe.msgprint( frappe._("{0} {1} already exists").format(doctype, name)) raise # update recent documents run_onload(doc) frappe.get_user().update_recent(doc.doctype, doc.name) send_updated_docs(doc)
def savedocs(doc, action): """save / submit / update doclist""" try: doc = frappe.get_doc(json.loads(doc)) set_local_name(doc) # action doc.docstatus = {"Save":0, "Submit": 1, "Update": 1, "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 "", doc.name or "", None) frappe.msgprint(frappe._("{0} {1} already exists").format(doctype, name)) raise # update recent documents 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._('Did not save')) frappe.errprint(frappe.utils.get_traceback()) raise
def savedocs(doc, action): """save / submit / update doclist""" try: doc = frappe.get_doc(json.loads(doc)) set_local_name(doc) # action doc.docstatus = { "Save": 0, "Submit": 1, "Update": 1, "Cancel": 2 }[action] if doc.docstatus == 1: doc.submit() else: doc.save() # update recent documents run_onload(doc) send_updated_docs(doc) frappe.msgprint(frappe._("Saved"), indicator='green', alert=True) except Exception: frappe.errprint(frappe.utils.get_traceback()) raise
def test_newsletter_status(self): """Test for Newsletter's stats on onload event""" newsletter = self.get_newsletter() newsletter.email_sent = True # had to use run_onload as calling .onload directly bought weird errors # like TestNewsletter has no attribute "_TestNewsletter__onload" run_onload(newsletter) self.assertIsInstance(newsletter.get("__onload").status_count, dict)
def savedocs(): """save / submit / update doclist""" try: doc = frappe.get_doc(json.loads(frappe.form_dict.doc)) set_local_name(doc) # action doc.docstatus = {"Save":0, "Submit": 1, "Update": 1, "Cancel": 2}[frappe.form_dict.action] try: doc.save() except frappe.NameError, e: doctype, name, original_exception = e if isinstance(e, tuple) else (doc.doctype or "", doc.name or "", None) frappe.msgprint(frappe._("{0} {1} already exists").format(doctype, name)) raise # update recent documents run_onload(doc) frappe.get_user().update_recent(doc.doctype, doc.name) send_updated_docs(doc)