fix: check if doc_before_save exists

This commit is contained in:
prssanna 2019-12-31 12:24:30 +05:30
parent 173960e50b
commit 764f18e2e9

View file

@ -59,13 +59,14 @@ class Workflow(Document):
def update_doc_status(self):
doc_before_save = self.get_doc_before_save()
for current_doc_state, doc_before_save_state in zip(self.states, doc_before_save.states):
if not doc_before_save_state.doc_status == current_doc_state.doc_status:
frappe.db.set_value(self.document_type,
{self.workflow_state_field: doc_before_save_state.state},
'docstatus',
current_doc_state.doc_status
)
if doc_before_save:
for current_doc_state, doc_before_save_state in zip(self.states, doc_before_save.states):
if not doc_before_save_state.doc_status == current_doc_state.doc_status:
frappe.db.set_value(self.document_type,
{self.workflow_state_field: doc_before_save_state.state},
'docstatus',
current_doc_state.doc_status
)
def validate_docstatus(self):
def get_state(state):