refactor: use `job_id` instead of `job_name` (#35242)
depends on https://github.com/frappe/frappe/pull/20951
diff --git a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py
index d8880f7..003a43c 100644
--- a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py
+++ b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py
@@ -53,19 +53,20 @@
if "Bank Account" not in json.dumps(preview["columns"]):
frappe.throw(_("Please add the Bank Account column"))
- from frappe.utils.background_jobs import is_job_queued
+ from frappe.utils.background_jobs import is_job_enqueued
from frappe.utils.scheduler import is_scheduler_inactive
if is_scheduler_inactive() and not frappe.flags.in_test:
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
- if not is_job_queued(self.name):
+ job_id = f"bank_statement_import::{self.name}"
+ if not is_job_enqueued(job_id):
enqueue(
start_import,
queue="default",
timeout=6000,
event="data_import",
- job_name=self.name,
+ job_id=job_id,
data_import=self.name,
bank_account=self.bank_account,
import_file_path=self.import_file,
diff --git a/erpnext/accounts/doctype/ledger_merge/ledger_merge.py b/erpnext/accounts/doctype/ledger_merge/ledger_merge.py
index 7cd6d04..381083b 100644
--- a/erpnext/accounts/doctype/ledger_merge/ledger_merge.py
+++ b/erpnext/accounts/doctype/ledger_merge/ledger_merge.py
@@ -4,7 +4,7 @@
import frappe
from frappe import _
from frappe.model.document import Document
-from frappe.utils.background_jobs import is_job_queued
+from frappe.utils.background_jobs import is_job_enqueued
from erpnext.accounts.doctype.account.account import merge_account
@@ -17,13 +17,14 @@
if is_scheduler_inactive() and not frappe.flags.in_test:
frappe.throw(_("Scheduler is inactive. Cannot merge accounts."), title=_("Scheduler Inactive"))
- if not is_job_queued(self.name):
+ job_id = f"ledger_merge::{self.name}"
+ if not is_job_enqueued(job_id):
enqueue(
start_merge,
queue="default",
timeout=6000,
event="ledger_merge",
- job_name=self.name,
+ job_id=job_id,
docname=self.name,
now=frappe.conf.developer_mode or frappe.flags.in_test,
)
diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py
index 47c2ceb..680afb1 100644
--- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py
+++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py
@@ -6,7 +6,7 @@
from frappe import _, scrub
from frappe.model.document import Document
from frappe.utils import flt, nowdate
-from frappe.utils.background_jobs import enqueue, is_job_queued
+from frappe.utils.background_jobs import enqueue, is_job_enqueued
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
get_accounting_dimensions,
@@ -212,13 +212,15 @@
if is_scheduler_inactive() and not frappe.flags.in_test:
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
- if not is_job_queued(self.name):
+ job_id = f"opening_invoice::{self.name}"
+
+ if not is_job_enqueued(job_id):
enqueue(
start_import,
queue="default",
timeout=6000,
event="opening_invoice_creation",
- job_name=self.name,
+ job_id=job_id,
invoices=invoices,
now=frappe.conf.developer_mode or frappe.flags.in_test,
)
diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
index b1e2208..d8aed21 100644
--- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
+++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
@@ -9,7 +9,7 @@
from frappe.model.document import Document
from frappe.model.mapper import map_child_doc, map_doc
from frappe.utils import cint, flt, get_time, getdate, nowdate, nowtime
-from frappe.utils.background_jobs import enqueue, is_job_queued
+from frappe.utils.background_jobs import enqueue, is_job_enqueued
from frappe.utils.scheduler import is_scheduler_inactive
@@ -483,15 +483,15 @@
closing_entry = kwargs.get("closing_entry") or {}
- job_name = closing_entry.get("name")
- if not is_job_queued(job_name):
+ job_id = "pos_invoice_merge::" + str(closing_entry.get("name"))
+ if not is_job_enqueued(job_id):
enqueue(
job,
**kwargs,
queue="long",
timeout=10000,
event="processing_merge_logs",
- job_name=job_name,
+ job_id=job_id,
now=frappe.conf.developer_mode or frappe.flags.in_test
)