mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 00:55:02 +00:00
refactor: ability to process in single transaction
(cherry picked from commit a158b825d7)
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user