refactor: barebones hook on all doctypes with 'company' field
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 308e6ca..492ae70 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -309,7 +309,10 @@
 
 doc_events = {
 	"*": {
-		"validate": "erpnext.support.doctype.service_level_agreement.service_level_agreement.apply",
+		"validate": [
+			"erpnext.support.doctype.service_level_agreement.service_level_agreement.apply",
+			"erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record.check_for_running_deletion_job",
+		],
 	},
 	tuple(period_closing_doctypes): {
 		"validate": "erpnext.accounts.doctype.accounting_period.accounting_period.validate_accounting_period_on_doc_save",
diff --git a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py
index be161e3..5a49a7d 100644
--- a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py
+++ b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py
@@ -450,3 +450,24 @@
 	doctypes_to_be_ignored.extend(frappe.get_hooks("company_data_to_be_ignored") or [])
 
 	return doctypes_to_be_ignored
+
+
+def check_for_running_deletion_job(doc, method=None):
+	df = qb.DocType("DocField")
+	if (
+		not_allowed := qb.from_(df)
+		.select(df.parent)
+		.where((df.fieldname == "company") & (df.parent == doc.doctype))
+		.run()
+	):
+		if running_deletion_jobs := frappe.db.get_all(
+			"Transaction Deletion Record",
+			filters={"docstatus": 1, "company": doc.company, "status": "Running"},
+		):
+			frappe.throw(
+				_(
+					"Transaction Deletion job {0} is running for this Company. Cannot make any transactions until the deletion job is completed"
+				).format(
+					get_link_to_form("Transaction Deletion Record", running_deletion_jobs[0].name)
+				)
+			)