From 2cf19b79ac09f502a3bb72fab170e21bc9ed63c1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 5 Oct 2016 18:57:35 +0530 Subject: [PATCH 1/2] Commit after locking and unlocking while queuing action --- frappe/model/document.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/frappe/model/document.py b/frappe/model/document.py index ea1489b6c8..6b4bc96022 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') + '

' + msg) - - doc.notify_update() - except Exception: - # add a comment (?) - doc.add_comment('Comment', - _('Action Failed') + '
' + frappe.get_traceback() + '
') - doc.notify_update() From 110dbc38ce9c841e706a6330a40377b7983052ea Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 5 Oct 2016 19:29:51 +0600 Subject: [PATCH 2/2] bumped to version 7.0.42 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index e8fbba56c9..d932de2b63 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template -__version__ = "7.0.41" +__version__ = "7.0.42" local = Local()