From c88e58048a61eed12e8cabbb2a27d842b3010edb Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 6 Jul 2011 13:02:05 +0530 Subject: [PATCH] doclist.py: check submission before cancel --- cgi-bin/webnotes/model/doclist.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cgi-bin/webnotes/model/doclist.py b/cgi-bin/webnotes/model/doclist.py index 9ba179aff3..36174d6282 100644 --- a/cgi-bin/webnotes/model/doclist.py +++ b/cgi-bin/webnotes/model/doclist.py @@ -197,6 +197,8 @@ class DocList: """ Save & Submit - set docstatus = 1, run "on_submit" """ + if self.doc.docstatus != 0: + msgprint("Only draft can be submitted", raise_exception=1) self.to_docstatus = 1 self.save() self.run_method('on_submit') @@ -205,6 +207,8 @@ class DocList: """ Cancel - set docstatus 2, run "on_cancel" """ + if self.doc.docstatus != 1: + msgprint("Only submitted can be cancelled", raise_exception=1) self.to_docstatus = 2 self.prepare_for_save(1) self.save_main()