Skip to content

Commit

Permalink
feat: nudge for all DocTypes that can be disabled, not deleted (frapp…
Browse files Browse the repository at this point in the history
…e#27067)

Co-authored-by: Suraj Shetty <[email protected]>
  • Loading branch information
barredterra and surajshetty3416 authored Jul 11, 2024
1 parent 0199069 commit fd9e80e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 0 additions & 7 deletions frappe/core/doctype/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
toggle_notifications,
)
from frappe.desk.notifications import clear_notifications
from frappe.model.delete_doc import check_if_doc_is_linked
from frappe.model.document import Document
from frappe.query_builder import DocType
from frappe.rate_limiter import rate_limit
Expand Down Expand Up @@ -551,12 +550,6 @@ def on_trash(self):
note.remove(row)
note.save(ignore_permissions=True)

# Ask user to disable instead if document is still linked
try:
check_if_doc_is_linked(self)
except frappe.LinkExistsError:
frappe.throw(_("You can disable the user instead of deleting it."), frappe.LinkExistsError)

def before_rename(self, old_name, new_name, merge=False):
# if merging, delete the old user notification settings
if merge:
Expand Down
13 changes: 11 additions & 2 deletions frappe/model/delete_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,17 @@ def delete_doc(

# check if links exist
if not force:
check_if_doc_is_linked(doc)
check_if_doc_is_dynamically_linked(doc)
try:
check_if_doc_is_linked(doc)
check_if_doc_is_dynamically_linked(doc)
except frappe.LinkExistsError as e:
if doc.meta.has_field("enabled") or doc.meta.has_field("disabled"):
frappe.throw(
_("You can disable this {0} instead of deleting it.").format(_(doctype)),
frappe.LinkExistsError,
)
else:
raise e

update_naming_series(doc)
delete_from_table(doctype, name, ignore_doctypes, doc)
Expand Down

0 comments on commit fd9e80e

Please sign in to comment.