8000 fix: don't update docstatus (backport #24216) by mergify[bot] · Pull Request #24221 · frappe/frappe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: don't update docstatus (backport #24216) #24221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions frappe/workflow/doctype/workflow/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,6 @@ def test_if_workflow_actions_were_processed_using_user(self):
self.assertEqual(workflow_actions[0].status, "Completed")
frappe.set_user("Administrator")

def test_update_docstatus(self):
todo = create_new_todo()
apply_workflow(todo, "Approve")

self.workflow._update_state_docstatus = True
self.workflow.states[1].doc_status = 0
self.workflow.save()
todo.reload()
self.assertEqual(todo.docstatus, 0)
self.workflow.states[1].doc_status = 1
self.workflow.save()
todo.reload()
self.assertEqual(todo.docstatus, 1)

self.workflow.states[1].doc_status = 0
self.workflow.save()

self.workflow._update_state_docstatus = False
self.workflow.states[1].doc_status = 1
self.workflow.save()
todo.reload()
self.assertEqual(todo.docstatus, 0)

self.workflow.states[1].doc_status = 0
self.workflow.save()

def test_if_workflow_set_on_action(self):
self.workflow._update_state_docstatus = True
self.workflow.states[1].doc_status = 1
Expand Down 8000
29 changes: 0 additions & 29 deletions frappe/workflow/doctype/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def validate(self):
self.validate_docstatus()

def on_update(self):
self.update_doc_status()
frappe.clear_cache(doctype=self.document_type)

def create_custom_field_for_workflow_state(self):
Expand Down Expand Up @@ -84,34 +83,6 @@ def update_default_workflow_status(self):

docstatus_map[d.doc_status] = d.state

def update_doc_status(self):
"""
Checks if the docstatus of a state was updated.
If yes then the docstatus of the document with same state will be updated
"""

if not self.get("_update_state_docstatus"):
return

doc_before_save = self.get_doc_before_save()
before_save_states, new_states = {}, {}
if doc_before_save:
for d in doc_before_save.states:
before_save_states[d.state] = d
for d in self.states:
new_states[d.state] = d

for key in new_states:
if key in before_save_states:
if not new_states[key].doc_status == before_save_states[key].doc_status:
frappe.db.set_value(
self.document_type,
{self.workflow_state_field: before_save_states[key].state},
"docstatus",
new_states[key].doc_status,
update_modified=False,
)

def validate_docstatus(self):
def get_state(state):
for s in self.states:
Expand Down
0