diff --git a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.json b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.json index 688b14a808a..e03e1695e0e 100644 --- a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.json +++ b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.json @@ -20,7 +20,8 @@ "section_break_tbej", "doctypes", "doctypes_to_be_ignored", - "amended_from" + "amended_from", + "process_in_single_transaction" ], "fields": [ { @@ -129,12 +130,18 @@ { "fieldname": "section_break_qpwb", "fieldtype": "Section Break" + }, + { + "default": "0", + "fieldname": "process_in_single_transaction", + "fieldtype": "Check", + "label": "Process in Single Transaction" } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2024-03-19 17:47:04.490196", + "modified": "2024-03-20 14:58:15.086360", "modified_by": "Administrator", "module": "Setup", "name": "Transaction Deletion Record", 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 2140b519f4c..a144525fe13 100644 --- a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py +++ b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py @@ -39,6 +39,7 @@ class TransactionDeletionRecord(Document): doctypes_to_be_ignored: DF.Table[TransactionDeletionRecordItem] error_log: DF.LongText | None initialize_doctypes_table: DF.Check + process_in_single_transaction: DF.Check reset_company_default_values: DF.Check status: DF.Literal["Queued", "Running", "Failed", "Completed", "Cancelled"] # end: auto-generated types @@ -139,18 +140,19 @@ class TransactionDeletionRecord(Document): # Generate Job Id to uniquely identify each task for this document job_id = self.generate_job_name_for_task(task) - frappe.enqueue( - "frappe.utils.background_jobs.run_doc_method", - doctype=self.doctype, - name=self.name, - doc_method="execute_task", - job_id=job_id, - queue="long", - enqueue_after_commit=True, - task_to_execute=task, - ) - - # todo: add a non-background job based approach as well + if self.process_in_single_transaction: + self.execute_task(task_to_execute=task) + else: + frappe.enqueue( + "frappe.utils.background_jobs.run_doc_method", + doctype=self.doctype, + name=self.name, + doc_method="execute_task", + job_id=job_id, + queue="long", + enqueue_after_commit=True, + task_to_execute=task, + ) def execute_task(self, task_to_execute: str | None = None): if task_to_execute: