From 45edd310e1e863858d2e0846bcc42c4498bf0cee Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 25 Apr 2018 17:35:49 +0530 Subject: [PATCH] Don't allow submitting/cancelling already submitted/cancelled docs (#5484) --- frappe/desk/doctype/bulk_update/bulk_update.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frappe/desk/doctype/bulk_update/bulk_update.py b/frappe/desk/doctype/bulk_update/bulk_update.py index c92d892d8d..023cf527be 100644 --- a/frappe/desk/doctype/bulk_update/bulk_update.py +++ b/frappe/desk/doctype/bulk_update/bulk_update.py @@ -41,21 +41,25 @@ def submit_cancel_or_update_docs(doctype, docnames, action='submit', data=None): for i, d in enumerate(docnames, 1): doc = frappe.get_doc(doctype, d) try: - if action == 'submit': + message = '' + if action == 'submit' and doc.docstatus==0: doc.submit() message = _('Submiting {0}').format(doctype) - elif action == 'cancel': + elif action == 'cancel' and doc.docstatus==1: doc.cancel() message = _('Cancelling {0}').format(doctype) - elif action == 'update': + elif action == 'update' and doc.docstatus < 2: doc.update(data) doc.save() message = _('Updating {0}').format(doctype) + else: + failed.append(d) show_progress(docnames, message, i, d) except Exception: failed.append(d) + return failed def show_progress(docnames, message, i, description):