Skip to content

Commit

Permalink
fix: get workflow_state_fieldname instead of setting workflow_state t…
Browse files Browse the repository at this point in the history
…o none

(cherry picked from commit ee9cb43)
  • Loading branch information
shariquerik authored and mergify[bot] committed Apr 3, 2023
1 parent 6206dc0 commit 3249aa2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frappe/core/doctype/deleted_document/deleted_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from frappe import _
from frappe.desk.doctype.bulk_update.bulk_update import show_progress
from frappe.model.document import Document
from frappe.model.workflow import get_workflow_name


class DeletedDocument(Document):
Expand All @@ -30,8 +31,11 @@ def restore(name, alert=True):
except frappe.DocstatusTransitionError:
frappe.msgprint(_("Cancelled Document restored as Draft"))
doc.docstatus = 0
if doc.workflow_state:
doc.workflow_state = None
active_workflow = get_workflow_name(doc.doctype)
if active_workflow:
workflow_state_fieldname = frappe.get_value("Workflow", active_workflow, "workflow_state_field")
if doc.get(workflow_state_fieldname):
doc.set(workflow_state_fieldname, None)
doc.insert()

doc.add_comment("Edit", _("restored {0} as {1}").format(deleted.deleted_name, doc.name))
Expand Down

0 comments on commit 3249aa2

Please sign in to comment.