diff --git a/frappe/model/document.py b/frappe/model/document.py index ebf5b9e95f..f3cdec17d6 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -974,7 +974,6 @@ class Document(BaseDocument): def queue_action(self, action, **kwargs): '''Run an action in background. If the action has an inner function, like _submit for submit, it will call that instead''' - if action in ('save', 'submit', 'cancel'): # set docstatus explicitly again due to inconsistent action self.docstatus = {'save':0, 'submit':1, 'cancel': 2}[action] @@ -988,6 +987,7 @@ class Document(BaseDocument): action = '_' + action self.lock() + frappe.db.commit() enqueue('frappe.model.document.execute_action', doctype=self.doctype, name=self.name, action=action, **kwargs) @@ -995,9 +995,10 @@ def execute_action(doctype, name, action, **kwargs): '''Execute an action on a document (called by background worker)''' doc = frappe.get_doc(doctype, name) doc.unlock() + frappe.db.commit() try: getattr(doc, action)(**kwargs) - except frappe.ValidationError: + except Exception: # add a comment (?) if frappe.local.message_log: msg = json.loads(frappe.local.message_log[-1]).get('message') @@ -1005,11 +1006,4 @@ def execute_action(doctype, name, action, **kwargs): msg = '
' + frappe.get_traceback() + '
'
doc.add_comment('Comment', _('Action Failed') + '' + frappe.get_traceback() + '
')
-
doc.notify_update()